Skip to main content

Module wgpu

Module wgpu 

Source
Available on crate feature wgpu only.
Expand description

Configure a wgpu runtime or share an application’s existing wgpu setup. Initialize wgpu through Device::wgpu_options.

In browsers, call Device::wgpu_options().init_async().await? before creating models or tensors. Use the returned Device for subsequent operations. Native applications can use .init() instead.

use burn_tensor::{Device, Tensor};

let device = Device::wgpu_options().tasks_max(32).init_async().await?;
let input = Tensor::<2>::ones([2, 3], &device);

Supply a WgpuSetup with .setup(...) to use an existing application’s device and queue. Register it once, then pass or clone the returned Burn device into models. Repeated registration of the same handles is not detected. Registering a setup does not change which runtime Device::default selects.

wgpu exposes the exact wgpu version whose handles this runtime accepts. Sharing handles does not convert tensors into buffers or wait for GPU work: flush pending Burn work before submitting external consumers on the shared queue, and keep shared allocations alive until those consumers finish.

Re-exports§

pub use wgpu;

Structs§

WgpuOptions
Options for initializing Burn’s wgpu runtime.
WgpuSetup
A complete setup used to run wgpu.
WgpuSetupOptions
Runtime options for registering an existing wgpu setup.

Enums§

MemoryConfiguration
High level configuration of memory management.
WgpuBackend
The graphics API a WgpuDevice comes up on, which also settles the shader compiler it is fed: SPIR-V on Vulkan, MSL on Metal, WGSL elsewhere.
WgpuInitError
A recoverable failure while acquiring or registering a wgpu runtime.