#[non_exhaustive]#[repr(u16)]pub enum IndexingKind {
Gather = 0,
GatherBackward = 1,
ScatterAdd = 2,
IndexSelect = 3,
IndexSelectBackward = 4,
MaskedFill = 5,
MaskedFillBackward = 6,
OneHot = 7,
Nonzero = 8,
Scatter = 9,
IndexAdd = 10,
}Expand description
Indexing / scatter / gather op discriminant — Category L from the comprehensive plan.
Stored as u16 in crate::KernelSku::op when
category == OpCategory::Indexing. Phase 7 Milestone 7.3 wires:
Self::Gather(FW + BW):out[i] = src[index[i]]along a dim.Self::ScatterAdd:out[index[i]] += updates[i]along a dim (atomicAdd, dup-safe).Self::IndexSelect(FW + BW):out[..., j, ...] = src[..., idx[j], ...]with a 1-D i32 idx tensor.Self::MaskedFill(FW + BW):out[i] = mask[i] ? value : src[i].Self::OneHot(FW only — non-differentiable):out[..., c] = 1 if c == src[...] else 0.Self::Nonzero(FW only): coordinates where input != 0, returned as an[k, rank]i32 table plus a count.
Index dtype is i32 only in the trailblazer (i64 deferred).
Out-of-bounds and negative indices are treated as no-ops (the kernel
skips them — PyTorch-style negative wrap-around is deferred).
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Gather = 0
gather(src, dim, index) — out[..., j, ...] = src[..., index[..., j, ...], ...]
along the specified gather dimension. PyTorch torch.gather.
GatherBackward = 1
Gradient of Self::Gather: scatters dout into dsrc along
the gather dim with atomicAdd (dup-safe). Different signature
from Self::ScatterAdd because the dst is dsrc and the
index pattern matches the FW gather coordinates exactly.
ScatterAdd = 2
scatter_add(out, dim, index, updates) —
out[..., index[..., j, ...], ...] += updates[..., j, ...]
(atomicAdd). PyTorch torch.scatter_add_.
IndexSelect = 3
index_select(src, dim, idx) —
out[..., j, ...] = src[..., idx[j], ...] with a 1-D i32 idx
tensor. Faster / simpler than gather when the index tensor
is 1-D. PyTorch torch.index_select.
IndexSelectBackward = 4
Gradient of Self::IndexSelect: scatter-add dout into dsrc
along select_dim using idx (atomicAdd).
MaskedFill = 5
masked_fill(src, mask, value) —
out[i] = mask[i] ? value : src[i]. PyTorch
torch.Tensor.masked_fill.
MaskedFillBackward = 6
Gradient of Self::MaskedFill: dsrc[i] = mask[i] ? 0 : dout[i].
value is a non-differentiable scalar.
OneHot = 7
one_hot(src, num_classes) —
out[indices..., c] = 1 if c == src[indices...] else 0. Input
dtype is i32 (class indices); output dtype is configurable.
PyTorch torch.nn.functional.one_hot. Non-differentiable.
Nonzero = 8
nonzero(x) — coordinates where x != 0. Returns an
[k, rank] i32 coordinate table plus a count. PyTorch
torch.nonzero. Output ordering is NOT row-major (atomic-counter
races); callers that need sorted output sort afterward.
Scatter = 9
scatter(out, dim, index, updates) —
out[..., index[..., j, ...], ...] = updates[..., j, ...]
(NO accumulation; last writer wins on duplicate-target races).
PyTorch torch.scatter_ (the in-place pure-assign variant).
Distinct from Self::ScatterAdd. Phase 39 (Fuel 6c.4 Gap 5).
IndexAdd = 10
index_add(dst, dim, idx, src) —
dst[idx[i], ...] += src[i, ...] along add_dim (atomicAdd-Σ).
PyTorch torch.Tensor.index_add_. Algorithmically identical to
Self::IndexSelectBackward but exposed under a non-autograd-
flavored name (and with broader dtype coverage). Phase 39
(Fuel 6c.4 Gap 5).
Trait Implementations§
Source§impl Clone for IndexingKind
impl Clone for IndexingKind
Source§fn clone(&self) -> IndexingKind
fn clone(&self) -> IndexingKind
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for IndexingKind
Source§impl Debug for IndexingKind
impl Debug for IndexingKind
impl Eq for IndexingKind
Source§impl Hash for IndexingKind
impl Hash for IndexingKind
Source§impl PartialEq for IndexingKind
impl PartialEq for IndexingKind
Source§fn eq(&self, other: &IndexingKind) -> bool
fn eq(&self, other: &IndexingKind) -> bool
self and other values to be equal, and is used by ==.