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>
impl<'a> GraphInstructionView<'a>
Sourcepub fn op(&self) -> GraphOpView<'a>
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));Sourcepub fn op_name(&self) -> &'static str
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");Sourcepub fn input_slots(&self) -> &'a [usize]
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);Sourcepub fn output_slots(&self) -> &'a [usize]
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);Sourcepub fn dtype(&self) -> DType
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);Sourcepub fn static_output_shape(
&self,
output_index: usize,
input_shapes: &[&[usize]],
) -> Result<Vec<usize>, GraphProgramLoweringShapeError>
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>
impl<'a> Clone for GraphInstructionView<'a>
Source§fn clone(&self) -> GraphInstructionView<'a>
fn clone(&self) -> GraphInstructionView<'a>
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for GraphInstructionView<'_>
impl Debug for GraphInstructionView<'_>
impl<'a> Copy for GraphInstructionView<'a>
Auto Trait Implementations§
impl<'a> Freeze for GraphInstructionView<'a>
impl<'a> !RefUnwindSafe for GraphInstructionView<'a>
impl<'a> Send for GraphInstructionView<'a>
impl<'a> Sync for GraphInstructionView<'a>
impl<'a> Unpin for GraphInstructionView<'a>
impl<'a> UnsafeUnpin for GraphInstructionView<'a>
impl<'a> !UnwindSafe for GraphInstructionView<'a>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more