Enum DispatchDevice
pub enum DispatchDevice {
Flex(FlexDevice),
Autodiff(AutodiffDevice),
}Expand description
Represents a device for the Dispatch.
Each variant corresponds to a backend that the Dispatch can dispatch operations to.
§Example
use burn::DispatchDevice;
// One variant covers every cubecl runtime; the device inside says which.
#[cfg(feature = "cuda")]
let cuda_device = DispatchDevice::Cube(cubecl::Device::Cuda(Default::default()));
#[cfg(feature = "ndarray")]
let ndarray_device = DispatchDevice::NdArray(Default::default());Variants§
Flex(FlexDevice)
The Flex backend device (CPU-only).
Autodiff(AutodiffDevice)
The autodiff enabled backend device.
Implementations§
§impl DispatchDevice
impl DispatchDevice
pub fn autodiff(device: impl Into<DispatchDevice>) -> DispatchDevice
pub fn autodiff(device: impl Into<DispatchDevice>) -> DispatchDevice
Creates a new DispatchDevice with
automatic differentiation enabled.
pub fn autodiff_with_gradient_checkpointing(
device: impl Into<DispatchDevice>,
checkpointing: GradientCheckpointingStrategy,
) -> DispatchDevice
pub fn autodiff_with_gradient_checkpointing( device: impl Into<DispatchDevice>, checkpointing: GradientCheckpointingStrategy, ) -> DispatchDevice
Creates a new DispatchDevice with automatic differentiation and the provided gradient
checkpointing strategy enabled.
pub fn inner(self) -> DispatchDevice
pub fn inner(self) -> DispatchDevice
Returns the inner device, without autodiff (when enabled).
Trait Implementations§
§impl Clone for DispatchDevice
impl Clone for DispatchDevice
§fn clone(&self) -> DispatchDevice
fn clone(&self) -> DispatchDevice
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more§impl Debug for DispatchDevice
impl Debug for DispatchDevice
§impl Default for DispatchDevice
impl Default for DispatchDevice
§fn default() -> DispatchDevice
fn default() -> DispatchDevice
Select an enabled backend in this order: CUDA, Metal, ROCm, Vulkan, WebGPU,
wgpu, CPU, LibTorch, Flex, Remote, NdArray. BURN_DEVICE overrides this in
std builds. Capture devices must be constructed explicitly.
The metal, vulkan, and webgpu overrides require their matching Cargo features
and pin the graphics API. Explicit Metal selection requires native MSL support.
The wgpu override keeps automatic API and compiler selection with WGSL fallback.
Panics when no execution backend is enabled, or when BURN_DEVICE names an unknown
backend or one whose Cargo feature is not enabled.
§impl Device for DispatchDevice
impl Device for DispatchDevice
§impl DeviceOps for DispatchDevice
impl DeviceOps for DispatchDevice
impl Eq for DispatchDevice
§impl From<FlexDevice> for DispatchDevice
Available on crate feature flex only.
impl From<FlexDevice> for DispatchDevice
flex only.§fn from(device: FlexDevice) -> DispatchDevice
fn from(device: FlexDevice) -> DispatchDevice
§impl PartialEq for DispatchDevice
impl PartialEq for DispatchDevice
§fn eq(&self, other: &DispatchDevice) -> bool
fn eq(&self, other: &DispatchDevice) -> bool
Compares devices based on hardware identity.
Returns true if both devices represent the same compute resource.
Note that this comparison ignores autodiff and checkpointing settings.
Auto Trait Implementations§
impl Freeze for DispatchDevice
impl RefUnwindSafe for DispatchDevice
impl Send for DispatchDevice
impl Sync for DispatchDevice
impl Unpin for DispatchDevice
impl UnsafeUnpin for DispatchDevice
impl UnwindSafe for DispatchDevice
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,
§impl<K, Q> Comparable<Q> for K
impl<K, Q> Comparable<Q> for K
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<K, Q> Equivalent<Q> for K
impl<K, Q> Equivalent<Q> for K
§fn equivalent(&self, key: &Q) -> bool
fn equivalent(&self, key: &Q) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§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§impl<T> Pointable for T
impl<T> Pointable for T
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> Read<Exclusive, BecauseExclusive> for Twhere
T: ?Sized,
Source§impl<R, P> ReadPrimitive<R> for P
impl<R, P> ReadPrimitive<R> for P
Source§fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
fn read_from_little_endian(read: &mut R) -> Result<Self, Error>
ReadEndian::read_from_little_endian().