Skip to main content

GraphInstructionView

Struct GraphInstructionView 

Source
pub struct GraphInstructionView<'a> { /* private fields */ }
Expand description

Read-only lowering view over one execution instruction.

§Examples

use tenferro_runtime::{GraphCompiler, TracedTensor};

let x = TracedTensor::from_vec_col_major(vec![1], vec![2.0_f64]).unwrap();
let mut compiler = GraphCompiler::new();
let program = compiler.compile(&x.neg()).unwrap();
let inst = program.lowering_view().instructions().next().unwrap();
assert_eq!(inst.output_slots().len(), 1);

Implementations§

Source§

impl<'a> GraphInstructionView<'a>

Source

pub fn op(&self) -> GraphOpView<'a>

Return the operation view for this instruction.

§Examples
use tenferro_runtime::{GraphCompiler, GraphOpView, TracedTensor};

let x = TracedTensor::from_vec_col_major(vec![1], vec![2.0_f64]).unwrap();
let mut compiler = GraphCompiler::new();
let program = compiler.compile(&x.neg()).unwrap();
let inst = program.lowering_view().instructions().next().unwrap();
assert!(matches!(inst.op(), GraphOpView::Negate));
Source

pub fn op_name(&self) -> &'static str

Return a stable operation name for diagnostics.

§Examples
use tenferro_runtime::{GraphCompiler, TracedTensor};

let x = TracedTensor::from_vec_col_major(vec![1], vec![2.0_f64]).unwrap();
let mut compiler = GraphCompiler::new();
let program = compiler.compile(&x.neg()).unwrap();
let inst = program.lowering_view().instructions().next().unwrap();
assert_eq!(inst.op_name(), "Negate");
Source

pub fn input_slots(&self) -> &'a [usize]

Return the input slots consumed by this instruction.

§Examples
use tenferro_runtime::{GraphCompiler, TracedTensor};

let x = TracedTensor::from_vec_col_major(vec![1], vec![2.0_f64]).unwrap();
let y = (&x + &x).unwrap();
let mut compiler = GraphCompiler::new();
let program = compiler.compile(&y).unwrap();
let inst = program.lowering_view().instructions().next().unwrap();
assert_eq!(inst.input_slots().len(), 2);
Source

pub fn output_slots(&self) -> &'a [usize]

Return the output slots written by this instruction.

§Examples
use tenferro_runtime::{GraphCompiler, TracedTensor};

let x = TracedTensor::from_vec_col_major(vec![1], vec![2.0_f64]).unwrap();
let mut compiler = GraphCompiler::new();
let program = compiler.compile(&x.neg()).unwrap();
let inst = program.lowering_view().instructions().next().unwrap();
assert_eq!(inst.output_slots().len(), 1);
Source

pub fn dtype(&self) -> DType

Return the dtype of this instruction’s output.

§Examples
use tenferro_runtime::{DType, GraphCompiler, TracedTensor};

let x = TracedTensor::from_vec_col_major(vec![1], vec![2.0_f64]).unwrap();
let mut compiler = GraphCompiler::new();
let program = compiler.compile(&x.neg()).unwrap();
let inst = program.lowering_view().instructions().next().unwrap();
assert_eq!(inst.dtype(), DType::F64);
Source

pub fn static_output_shape( &self, output_index: usize, input_shapes: &[&[usize]], ) -> Result<Vec<usize>, GraphProgramLoweringShapeError>

Resolve an exact static output shape for this instruction.

input_shapes must be ordered the same way as Self::input_slots.

§Examples
use tenferro_runtime::{GraphCompiler, TracedTensor};

let x = TracedTensor::from_vec_col_major(vec![1], vec![2.0_f64]).unwrap();
let mut compiler = GraphCompiler::new();
let program = compiler.compile(&x.neg()).unwrap();
let inst = program.lowering_view().instructions().next().unwrap();
assert_eq!(inst.static_output_shape(0, &[&[1]]).unwrap(), vec![1]);

Trait Implementations§

Source§

impl<'a> Clone for GraphInstructionView<'a>

Source§

fn clone(&self) -> GraphInstructionView<'a>

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for GraphInstructionView<'_>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'a> Copy for GraphInstructionView<'a>

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.