pub struct TensorOpFusion { /* private fields */ }Expand description
Stateful engine that fuses primitive tensor-op sequences into compound ops.
§Example
use ipfrs_tensorlogic::op_fusion::{TensorOp as FusionTensorOp, TensorOpFusion};
let mut engine = TensorOpFusion::new();
let ops = vec![
FusionTensorOp::Scale { factor: 2.0 },
FusionTensorOp::Bias { offset: 1.0 },
];
let plan = engine.fuse(ops);
assert_eq!(plan.fused_op_count, 1);
assert!((plan.reduction_ratio() - 0.5).abs() < 1e-10);Implementations§
Source§impl TensorOpFusion
impl TensorOpFusion
Sourcepub fn fuse(&mut self, ops: Vec<TensorOp>) -> FusionPlan
pub fn fuse(&mut self, ops: Vec<TensorOp>) -> FusionPlan
Fuse ops left-to-right using greedy matching and return a FusionPlan.
Sourcepub fn stats(&self) -> &FusionStats
pub fn stats(&self) -> &FusionStats
Return a reference to the accumulated statistics.
Sourcepub fn can_fuse(a: &TensorOp, b: &TensorOp) -> bool
pub fn can_fuse(a: &TensorOp, b: &TensorOp) -> bool
Return true when a and b form the start of a fuseable pattern.
This covers all two-op pairs that appear in any fusion rule:
- Scale → Bias (
ScaleBias) - Scale → Relu (start of
ScaleReluBias) - Relu → Bias (tail of
ScaleReluBias) - Clamp → Normalize (
ClampNormalize)
Trait Implementations§
Source§impl Debug for TensorOpFusion
impl Debug for TensorOpFusion
Source§impl Default for TensorOpFusion
impl Default for TensorOpFusion
Source§fn default() -> TensorOpFusion
fn default() -> TensorOpFusion
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for TensorOpFusion
impl RefUnwindSafe for TensorOpFusion
impl Send for TensorOpFusion
impl Sync for TensorOpFusion
impl Unpin for TensorOpFusion
impl UnsafeUnpin for TensorOpFusion
impl UnwindSafe for TensorOpFusion
Blanket Implementations§
impl<T> Allocation for T
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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