Nx backend implementation that delegates tensor operations to Burn via NIF.
This module implements the Nx.Backend behaviour, translating Nx tensor
operations into calls to the Rust NIF layer which executes them using
Burn's CubeCL backend for GPU acceleration.
Architecture
Axon model
↓
Nx.Defn graph
↓
ExBurn.Backend (Nx.Backend behaviour)
↓
ExBurn.Nif (Rustler NIF) ←→ ExCubecl (GPU buffers, kernels, pipelines)
↓
Burn Autodiff<CubeCL> (Rust)
↓
CubeCL kernels
↓
Metal (iOS) / Vulkan (Android) / CUDA → GPUUsage
Nx.default_backend(ExBurn.Backend)Implementation Notes
- Tensors are stored as opaque NIF references on the Rust side
- Data is serialized as binary (f32 little-endian) for NIF calls
- The backend struct holds the NIF reference, shape, and type
- For performance-critical paths, use
ExBurn.BurnBridgedirectly - All public callbacks raise
ExBurn.Erroron failure
Summary
Types
@type t() :: %ExBurn.Backend{ ref: reference(), shape: [non_neg_integer()], type: ExBurn.Tensor.burn_type() }
Functions
@spec random_normal( Nx.Tensor.t(), keyword() ) :: t()
@spec random_uniform( Nx.Tensor.t(), keyword() ) :: t()