High-level bridge for Burn operations.
This module provides a direct API to Burn tensor operations, bypassing the Nx abstraction layer for cases where you need more control or want to avoid the overhead of Nx ↔ Burn conversions.
Usage
# Create tensors directly
t1 = ExBurn.BurnBridge.zeros([3, 3], :f32)
t2 = ExBurn.BurnBridge.ones([3, 3], :f32)
# Perform operations
t3 = ExBurn.BurnBridge.add(t1, t2)
# Convert to Nx when needed
{:ok, nx_tensor} = ExBurn.BurnBridge.to_nx(t3)
Summary
Functions
Creates a GPU buffer via ExCubecl from a list of values.
Creates a GPU buffer via ExCubecl, raising on error.
Returns the shape of an ExCubecl buffer.
Returns the byte size of an ExCubecl buffer.
Returns information about the current compute device.
Returns the name of the active compute device.
Creates a tensor from an Nx tensor.
Checks whether a GPU (CUDA/Metal/Vulkan) is available via the NIF.
Creates a tensor filled with ones.
Creates a random tensor with uniform distribution.
Reads data from an ExCubecl buffer.
Converts a Burn tensor to Nx.
Creates a tensor filled with zeros.
Functions
@spec abs(ExBurn.Tensor.t()) :: ExBurn.Tensor.t()
@spec add(ExBurn.Tensor.t(), ExBurn.Tensor.t()) :: ExBurn.Tensor.t()
@spec buffer(list(), [non_neg_integer()], atom()) :: ExCubecl.buffer_ref()
Creates a GPU buffer via ExCubecl from a list of values.
Creates a GPU buffer via ExCubecl, raising on error.
@spec buffer_shape(ExCubecl.buffer_ref()) :: [non_neg_integer()]
Returns the shape of an ExCubecl buffer.
@spec buffer_size(ExCubecl.buffer_ref()) :: non_neg_integer()
Returns the byte size of an ExCubecl buffer.
@spec cross_entropy(ExBurn.Tensor.t(), ExBurn.Tensor.t()) :: ExBurn.Tensor.t()
@spec device_info() :: map()
Returns information about the current compute device.
@spec device_name() :: String.t()
Returns the name of the active compute device.
@spec div(ExBurn.Tensor.t(), ExBurn.Tensor.t()) :: ExBurn.Tensor.t()
@spec dropout(ExBurn.Tensor.t(), float(), boolean()) :: ExBurn.Tensor.t()
@spec exp(ExBurn.Tensor.t()) :: ExBurn.Tensor.t()
@spec free(ExBurn.Tensor.t()) :: :ok
@spec from_nx(Nx.Tensor.t()) :: ExBurn.Tensor.t()
Creates a tensor from an Nx tensor.
@spec gpu_available?() :: boolean()
Checks whether a GPU (CUDA/Metal/Vulkan) is available via the NIF.
@spec layer_norm(ExBurn.Tensor.t(), non_neg_integer(), float()) :: ExBurn.Tensor.t()
@spec log(ExBurn.Tensor.t()) :: ExBurn.Tensor.t()
@spec matmul(ExBurn.Tensor.t(), ExBurn.Tensor.t()) :: ExBurn.Tensor.t()
@spec mean(ExBurn.Tensor.t(), [non_neg_integer()] | nil) :: ExBurn.Tensor.t()
@spec mse(ExBurn.Tensor.t(), ExBurn.Tensor.t()) :: ExBurn.Tensor.t()
@spec mul(ExBurn.Tensor.t(), ExBurn.Tensor.t()) :: ExBurn.Tensor.t()
@spec neg(ExBurn.Tensor.t()) :: ExBurn.Tensor.t()
@spec ones([non_neg_integer()], ExBurn.Tensor.type()) :: ExBurn.Tensor.t()
Creates a tensor filled with ones.
@spec rand([non_neg_integer()], ExBurn.Tensor.type(), float(), float()) :: ExBurn.Tensor.t()
Creates a random tensor with uniform distribution.
@spec read_buffer(ExCubecl.buffer_ref()) :: binary()
Reads data from an ExCubecl buffer.
@spec relu(ExBurn.Tensor.t()) :: ExBurn.Tensor.t()
@spec reshape(ExBurn.Tensor.t(), [non_neg_integer()]) :: ExBurn.Tensor.t()
@spec sigmoid(ExBurn.Tensor.t()) :: ExBurn.Tensor.t()
@spec softmax(ExBurn.Tensor.t(), non_neg_integer()) :: ExBurn.Tensor.t()
@spec sqrt(ExBurn.Tensor.t()) :: ExBurn.Tensor.t()
@spec sub(ExBurn.Tensor.t(), ExBurn.Tensor.t()) :: ExBurn.Tensor.t()
@spec sum(ExBurn.Tensor.t(), [non_neg_integer()] | nil) :: ExBurn.Tensor.t()
@spec to_cpu(ExBurn.Tensor.t()) :: ExBurn.Tensor.t()
@spec to_gpu(ExBurn.Tensor.t()) :: ExBurn.Tensor.t()
@spec to_nx(ExBurn.Tensor.t()) :: Nx.Tensor.t()
Converts a Burn tensor to Nx.
@spec transpose(ExBurn.Tensor.t(), non_neg_integer(), non_neg_integer()) :: ExBurn.Tensor.t()
@spec zeros([non_neg_integer()], ExBurn.Tensor.type()) :: ExBurn.Tensor.t()
Creates a tensor filled with zeros.