#[repr(u8)]pub enum DispatchKey {
Cpu = 0,
Cuda = 1,
Meta = 2,
Sparse = 3,
Quantized = 4,
Nested = 5,
Autocast = 6,
Autograd = 7,
Vmap = 8,
Profiler = 9,
Tracer = 10,
}Expand description
One of the 16 possible dispatch keys, ordered from lowest to
highest priority. The u8 repr matches the bit position in
DispatchKeySet’s internal u16 bitmask, so the priority
ordering is both the enum declaration order and the numeric
order of the discriminants.
Keys are resolved highest-priority-first: the dispatcher walks from the largest discriminant down and picks the first key that has a registered kernel for the op.
Variants§
Cpu = 0
Backend: CPU — terminal key for CPU kernels.
Cuda = 1
Backend: CUDA — terminal key for CUDA kernels.
Meta = 2
Backend: Meta device — shape-only dry runs, no data.
Sparse = 3
Tensor contains sparse data. Sparse kernels intercept ops and either call a sparse-specific backend or densify and redispatch.
Quantized = 4
Tensor contains quantized values. Quantized kernels dequantize, redispatch, and requantize (for ops without native quantized kernels).
Nested = 5
Tensor is a nested/jagged tensor. Nested kernels iterate per-component and redispatch to the backend.
Autocast = 6
Auto-mixed-precision: cast inputs to the autocast dtype before redispatching. Higher priority than Quantized so AMP happens before quantization layering.
Autograd = 7
Autograd: record a backward node and redispatch with Autograd masked off. Highest-priority non-profiling key so the backward graph sees the post-dispatch view of each op.
Vmap = 8
Vmap (batched tensor): intercept ops and apply them over the batch dimension. Stacks above Autograd so batched forwards still see autograd semantics.
Profiler = 9
Profiler: record an entry in the active profiler before redispatching. Sits above Vmap so the profiler sees the outer call exactly once regardless of batching.
Tracer = 10
Tracer: emit an IR node into the active JIT trace. Highest priority so tracing happens before any other layering transforms the op.
Implementations§
Source§impl DispatchKey
impl DispatchKey
Trait Implementations§
Source§impl Clone for DispatchKey
impl Clone for DispatchKey
Source§fn clone(&self) -> DispatchKey
fn clone(&self) -> DispatchKey
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DispatchKey
impl Debug for DispatchKey
Source§impl Hash for DispatchKey
impl Hash for DispatchKey
Source§impl Ord for DispatchKey
impl Ord for DispatchKey
Source§fn cmp(&self, other: &DispatchKey) -> Ordering
fn cmp(&self, other: &DispatchKey) -> Ordering
1.21.0 · Source§fn max(self, other: Self) -> Selfwhere
Self: Sized,
fn max(self, other: Self) -> Selfwhere
Self: Sized,
Source§impl PartialEq for DispatchKey
impl PartialEq for DispatchKey
Source§impl PartialOrd for DispatchKey
impl PartialOrd for DispatchKey
impl Copy for DispatchKey
impl Eq for DispatchKey
impl StructuralPartialEq for DispatchKey
Auto Trait Implementations§
impl Freeze for DispatchKey
impl RefUnwindSafe for DispatchKey
impl Send for DispatchKey
impl Sync for DispatchKey
impl Unpin for DispatchKey
impl UnsafeUnpin for DispatchKey
impl UnwindSafe for DispatchKey
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Comparable<K> for Q
impl<Q, K> Comparable<K> for Q
Source§impl<T> DistributionExt for Twhere
T: ?Sized,
impl<T> DistributionExt for Twhere
T: ?Sized,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.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