pub struct BackendImpl {
pub kernel: KernelRef,
pub dtypes: &'static [DType],
pub cost: fn(&[Shape], &FusedOpParams, &BackendCapabilities) -> CostEstimate,
pub precision: PrecisionGuarantee,
pub caps: KernelCaps,
pub revision: KernelRevisionHash,
pub cost_expr: Option<&'static CompiledCostExpr>,
}Expand description
Per-backend kernel implementation for one fused op. The optimizer
reads this to (1) pre-resolve KernelRef for nodes it places on
this backend, (2) score routes against CostEstimate, and
(3) admit candidates against the per-route tolerance budget via
PrecisionGuarantee.
Function-pointer composition (no trait-object indirection) — the
registry stores BackendImpl values inline, the executor calls
the function pointer directly.
A single (FusedOpId, BackendId) decision point may have multiple
registered BackendImpls — one per dtype tuple, and potentially
multiple alternatives at the same dtype (e.g. cuBLAS bias-epilogue
vs CUTLASS bias-epilogue for (FUSED_LINEAR, [BF16,BF16,BF16,BF16], Cuda)). The route picker filters by Self::dtypes and ranks the
remaining alternatives by cost + precision.
Fields§
§kernel: KernelRefDispatch wrapper for this backend’s kernel for this fused op.
Same KernelRef signature as primitive-op kernels.
dtypes: &'static [DType]Dtype tuple this kernel is registered for. Convention mirrors
the binding-table key shape: typically [input1, input2, ..., output] per the existing register(table, op, &[dtype; N], backend, kernel) call sites. Using &'static [DType] keeps
BackendImpl Copy and lets registrations declare dtypes
inline as &[F32, F32, F32, F32] literals.
cost: fn(&[Shape], &FusedOpParams, &BackendCapabilities) -> CostEstimateCost-estimate function. Given the input shapes, the
per-instance fused-op params, and the backend’s capabilities,
returns a CostEstimate used for placement and route ranking.
precision: PrecisionGuaranteeNumerical precision properties of this kernel.
caps: KernelCapsLayout / capability flags (e.g. strided_input).
revision: KernelRevisionHashRevision hash — opaque identifier for the source-version of this
kernel. Persisted optimization caches use this to detect kernel
drift and invalidate stale cache entries (see
docs/architecture/11-persistence.md).
cost_expr: Option<&'static CompiledCostExpr>Declared cost AST compiled from the contract’s cost: field
(FKC gap-closure §2.3, Task 2.4). None when the contract
declared no cost expression, or for hand-written (non-FKC)
registrations. When present, crate::fused_cost::fused_layer1_cost
prefers it over the is_fused_cost_sentinel
decompose-derived fallback.
Trait Implementations§
Source§impl Clone for BackendImpl
impl Clone for BackendImpl
impl Copy for BackendImpl
Auto Trait Implementations§
impl Freeze for BackendImpl
impl RefUnwindSafe for BackendImpl
impl Send for BackendImpl
impl Sync for BackendImpl
impl Unpin for BackendImpl
impl UnsafeUnpin for BackendImpl
impl UnwindSafe for BackendImpl
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> ⓘ
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> ⓘ
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