#[non_exhaustive]pub enum FastOp {
Show 16 variants
RmsNorm {
eps: u32,
},
AddRmsNorm {
eps: u32,
},
RmsNormVjp {
eps: u32,
},
LayerNorm {
eps: u32,
},
LayerNormVjp {
eps: u32,
},
Rope {
dims: usize,
traditional: bool,
base: u32,
scale: u32,
forward: bool,
},
NormRope {
eps: Option<u32>,
dims: usize,
traditional: bool,
base: u32,
scale: u32,
offset: usize,
cache: bool,
},
DepthwiseConv1d {
stride: usize,
padding: usize,
dilation: usize,
},
Softmax,
LogSumExp,
CrossEntropy,
CrossEntropyVjp,
Attention {
scale: u32,
causal: bool,
mask: bool,
sinks: bool,
},
GatedDelta {
steps: bool,
},
GatherMm,
GatherQmm {
group_size: usize,
bits: u8,
transpose: bool,
},
}Expand description
A fused operation (see the module documentation).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
RmsNorm
(x, w): x / sqrt(mean(x²) + eps) · w over the last axis; w is 1-D or a scalar 1.
AddRmsNorm
(x, r, w): h = x + r and FastOp::RmsNorm of h (see add_rms_norm).
RmsNormVjp
(x, w, g): the gradients of FastOp::RmsNorm for x and w.
LayerNorm
(x, w, b): (x - mean) / sqrt(var + eps) · w + b over the last axis; w and b
are 1-D or the scalars 1 and 0.
LayerNormVjp
(x, w, b, g): the gradients of FastOp::LayerNorm for x, w and b.
Rope
(x, offset[, freqs]): rotary position embeddings of the first dims features.
Fields
NormRope
([cache,] x, w[, freqs]): norm_rope: each [b, h, l] row of x RMS-normalised
(with eps) and rotated as FastOp::Rope at position offset + l; written into
cache at the same positions, or returned as a new [B, H, L, D] array.
Fields
DepthwiseConv1d
(x, w): crate::conv1d with groups equal to the channels (depthwise).
Fields
Softmax
(x): softmax over the last axis, accumulated in float32.
LogSumExp
(x): log(sum(exp(x))) over the last axis, which becomes size 1.
CrossEntropy
(logits, targets): logsumexp(logits) - logits[target] per row, in float32.
CrossEntropyVjp
(logits, targets, loss, g): the gradient of FastOp::CrossEntropy for the logits.
Attention
(q, k, v[, mask][, sinks]): scaled dot-product attention (see
scaled_dot_product_attention).
Fields
GatedDelta
(q, k, v, g, beta, state): the gated delta rule (see gated_delta), with the
outputs and the final state (or every step’s, gated_delta_steps).
GatherMm
(a, b, lhs_indices, rhs_indices[, offsets]): matrix products of gathered batches
(see crate::gather_mm), as FastOp::GatherQmm in full precision.
GatherQmm
(x, w, scales, biases, lhs_indices, rhs_indices[, offsets]): quantized matrix
products of gathered batches (see crate::gather_qmm); the indices are uint32
and broadcast to the output’s batch shape. offsets (int32, one per batch of w)
marks where each weight batch’s rows start when the rows are sorted by it.
Trait Implementations§
impl Eq for FastOp
impl StructuralPartialEq for FastOp
Auto Trait Implementations§
impl Freeze for FastOp
impl RefUnwindSafe for FastOp
impl Send for FastOp
impl Sync for FastOp
impl Unpin for FastOp
impl UnsafeUnpin for FastOp
impl UnwindSafe for FastOp
Blanket Implementations§
impl<T> AutoreleaseSafe for Twhere
T: ?Sized,
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> 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