pub struct WgpuOptions { /* private fields */ }wgpu only.Expand description
Options for initializing Burn’s wgpu runtime.
Construct with Device::wgpu_options or Default::default. Options cover
device acquisition and runtime settings such as memory management and task batching.
Setters do not acquire a GPU. Initialization registers the selected runtime for reuse.
Dropping the returned device does not deregister that runtime.
Implementations§
Source§impl WgpuOptions
impl WgpuOptions
Sourcepub fn device_kind(self, kind: DeviceKind) -> Self
pub fn device_kind(self, kind: DeviceKind) -> Self
Select an adapter kind. Existing identifiers cannot be initialized here;
register an existing setup with Self::setup instead.
Browser selection follows the runtime’s power preferences; browsers do not expose native adapter indices. The default prefers a high-performance GPU.
Sourcepub fn graphics_api(self, api: WgpuBackend) -> Self
pub fn graphics_api(self, api: WgpuBackend) -> Self
Pin the graphics API, or let WgpuBackend::Auto choose it.
An explicit API never falls back to another API. This selects the graphics
API, not a shader compiler; the runtime chooses a supported compiler.
With the metal feature enabled, an explicit Metal selection requires native
MSL support. Initialization returns an error if it is unavailable; automatic
selection permits WGSL fallback.
Sourcepub fn memory_config(self, config: MemoryConfiguration) -> Self
pub fn memory_config(self, config: MemoryConfiguration) -> Self
Set the runtime’s memory allocation policy.
Sourcepub fn tasks_max(self, tasks: usize) -> Self
pub fn tasks_max(self, tasks: usize) -> Self
Set the maximum tasks aggregated into a GPU command. Must be nonzero.
Overrides CUBECL_WGPU_MAX_TASKS, including a malformed environment value.
Sourcepub fn setup(self, setup: WgpuSetup) -> WgpuSetupOptions
pub fn setup(self, setup: WgpuSetup) -> WgpuSetupOptions
Register existing wgpu handles instead of acquiring another device.
Memory and task options carry over. Explicit calls to Self::device_kind
or Self::graphics_api conflict with a supplied setup, even when those
options name defaults; WgpuSetupOptions::init returns an error.
Handles must belong to one coherent setup. Compiler selection follows the same backend and adapter checks as acquired setups. The supplied device must enable the selected compiler’s required features, including native extensions for SPIR-V or MSL; registration does not validate all of them.
Sourcepub fn init(self) -> Result<Device, WgpuInitError>
Available on non-target_family=wasm only.
pub fn init(self) -> Result<Device, WgpuInitError>
target_family=wasm only.Initialize the device synchronously on native targets.
Use Self::init_async when running in a browser or an async application.
§Errors
Returns acquisition, configuration, or registration errors.
Returns an error if the runtime for the selected device kind and graphics API has already been initialized, either explicitly or by a tensor operation. Runtime options must be set before first use.
Sourcepub async fn init_async(self) -> Result<Device, WgpuInitError>
pub async fn init_async(self) -> Result<Device, WgpuInitError>
Initialize the device asynchronously on native or browser targets.
§Errors
Returns acquisition, configuration, or registration errors.
Returns an error if the runtime for the selected device kind and graphics API has already been initialized, either explicitly or by a tensor operation. Runtime options must be set before first use.
Sourcepub fn init_with_setup(self) -> Result<(Device, WgpuSetup), WgpuInitError>
Available on non-target_family=wasm only.
pub fn init_with_setup(self) -> Result<(Device, WgpuSetup), WgpuInitError>
target_family=wasm only.Initialize synchronously and return the exact handles used by this runtime.
Share these handles with another wgpu component. Do not register the returned setup again; clone the accompanying Burn device to reuse it.
§Errors
Returns acquisition, configuration, or registration errors.
Returns an error if the runtime for the selected device kind and graphics API has already been initialized, either explicitly or by a tensor operation. Runtime options must be set before first use.
Sourcepub async fn init_with_setup_async(
self,
) -> Result<(Device, WgpuSetup), WgpuInitError>
pub async fn init_with_setup_async( self, ) -> Result<(Device, WgpuSetup), WgpuInitError>
Initialize asynchronously and return the exact handles used by this runtime.
Available on native and browser targets. The returned device is ready for tensor operations; the setup is ready to share with another wgpu component.
§Errors
Returns acquisition, configuration, or registration errors.
Returns an error if the runtime for the selected device kind and graphics API has already been initialized, either explicitly or by a tensor operation. Runtime options must be set before first use.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WgpuOptions
impl RefUnwindSafe for WgpuOptions
impl Send for WgpuOptions
impl Sync for WgpuOptions
impl Unpin for WgpuOptions
impl UnsafeUnpin for WgpuOptions
impl UnwindSafe for WgpuOptions
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> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait> (where Trait: Downcast) to Box<dyn Any>, which can then be
downcast into Box<dyn ConcreteType> where ConcreteType implements Trait.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait> (where Trait: Downcast) to Rc<Any>, which can then be further
downcast into Rc<ConcreteType> where ConcreteType implements Trait.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &Any’s vtable from &Trait’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait (where Trait: Downcast) to &Any. This is needed since Rust cannot
generate &mut Any’s vtable from &mut Trait’s.Source§impl<T> DowncastSend for T
impl<T> DowncastSend for T
Source§impl<T> DowncastSync for T
impl<T> DowncastSync for T
impl<T> ErasedDestructor for Twhere
T: 'static,
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