pub enum Segment {
Fused {
instructions: Vec<ExecInstruction>,
input_slots: Vec<usize>,
output_slots: Vec<usize>,
last_use: Vec<bool>,
},
Ffi(ExecInstruction),
Host(ExecInstruction),
}Expand description
A compiled execution segment.
Fused segments group consecutive non-host, non-FFI instructions that can share one backend execution session. FFI and host segments remain single-instruction boundaries in Phase 4.
§Examples
use tenferro::segment::{segment_exec_program, Segment};
use tenferro::exec::{ExecInstruction, ExecOp, ExecProgram};
use tenferro::DType;
let program = ExecProgram {
instructions: vec![
ExecInstruction {
op: ExecOp::Add,
input_slots: vec![0, 1],
output_slots: vec![2],
dtype: DType::F64,
output_shapes: vec![vec![]],
last_use: vec![false, true],
},
ExecInstruction {
op: ExecOp::Negate,
input_slots: vec![2],
output_slots: vec![3],
dtype: DType::F64,
output_shapes: vec![vec![]],
last_use: vec![true],
},
],
input_slots: vec![0, 1],
output_slots: vec![3],
n_slots: 4,
};
let segments = segment_exec_program(&program);
assert!(matches!(&segments[0], Segment::Fused { instructions, .. } if instructions.len() == 2));Variants§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Segment
impl RefUnwindSafe for Segment
impl Send for Segment
impl Sync for Segment
impl Unpin for Segment
impl UnsafeUnpin for Segment
impl UnwindSafe for Segment
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
fn rand<T>(&self, rng: &mut (impl Rng + ?Sized)) -> Twhere
Self: Distribution<T>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more