12 releases (7 breaking)

0.15.0 Oct 28, 2024
0.13.2 May 3, 2024
0.12.1 Feb 1, 2024
0.11.1 Dec 4, 2023
0.8.0 Jul 25, 2023

#714 in Machine learning

Download history 2212/week @ 2024-08-05 1651/week @ 2024-08-12 1649/week @ 2024-08-19 1756/week @ 2024-08-26 1421/week @ 2024-09-02 1596/week @ 2024-09-09 1257/week @ 2024-09-16 1688/week @ 2024-09-23 1446/week @ 2024-09-30 1274/week @ 2024-10-07 1607/week @ 2024-10-14 1561/week @ 2024-10-21 1932/week @ 2024-10-28 1463/week @ 2024-11-04 1172/week @ 2024-11-11 1272/week @ 2024-11-18

6,111 downloads per month
Used in 25 crates (3 directly)

MIT/Apache

2MB
45K SLoC

Burn WGPU Backend

Burn WGPU backend

Current Crates.io Version license

This crate provides a WGPU backend for Burn using the wgpu.

The backend supports Vulkan, Metal, DirectX11/12, OpenGL, WebGPU.

Usage Example

#[cfg(feature = "wgpu")]
mod wgpu {
    use burn_autodiff::Autodiff;
    use burn_wgpu::{Wgpu, WgpuDevice};
    use mnist::training;

    pub fn run() {
        let device = WgpuDevice::default();
        training::run::<Autodiff<Wgpu<f32, i32>>>(device);
    }
}

Configuration

You can set BURN_WGPU_MAX_TASKS to a positive integer that determines how many computing tasks are submitted in batches to the graphics API.

Alternative SPIR-V backend

When targeting Vulkan, the spirv feature flag can be enabled to enable the SPIR-V compiler backend, which performs significantly better than WGSL. This is especially true for matrix multiplication, where SPIR-V can make use of TensorCores and run at f16 precision. This isn't currently supported by WGSL. The compiler can also be selected at runtime by setting the corresponding generic parameter to either SpirV or Wgsl.

Platform Support

Option CPU GPU Linux MacOS Windows Android iOS WASM
Metal No Yes No Yes No No Yes No
Vulkan Yes Yes Yes Yes Yes Yes Yes No
OpenGL No Yes Yes Yes Yes Yes Yes No
WebGpu No Yes No No No No No Yes
Dx11/Dx12 No Yes No No Yes No No No

Dependencies

~37–73MB
~1.5M SLoC