ExCubecl (ExCubecl v0.1.0)

Copy Markdown View Source

ExCubecl - An Nx backend powered by CubeCL via Rust NIFs.

Provides tensor operations using a Rust NIF layer for compute. Operations not yet implemented in the Nif fall back to Nx.BinaryBackend.

Usage

iex> t = Nx.tensor([1.0, 2.0, 3.0], backend: ExCubecl.Backend)
iex> Nx.add(t, t)
#Nx.Tensor<
  f32[3]
  [2.0, 4.0, 6.0]
>

Supported types

  • {:f, 32} - 32-bit float
  • {:f, 64} - 64-bit float
  • {:s, 32} - 32-bit signed integer
  • {:s, 64} - 64-bit signed integer
  • {:u, 32} - 32-bit unsigned integer
  • {:u, 8} - 8-bit unsigned integer

Mobile (iOS / Android) support

ExCubecl provides a C FFI layer (ex_cubecl.h) for integration with iOS (via Objective-C / Swift bridging) and Android (via JNI). See the header at native/ex_cubecl_nif/include/ex_cubecl.h.

Summary

Functions

Checks if the NIF library is loaded and available.

Return the total byte size for a tensor of the given shape and type.

Returns information about the compute device/backend.

Create a tensor from a binary with the given shape and type.

Returns the list of supported tensor types.

Read a tensor's data into a binary.

Return the size in bytes of a single element for the given Nx type.

Returns the version of ExCubecl.

Functions

available?()

@spec available?() :: boolean()

Checks if the NIF library is loaded and available.

Returns true if the NIF can be loaded, false otherwise. Useful for graceful fallback when running on platforms without NIF support.

byte_size(shape, type)

@spec byte_size(tuple(), tuple()) :: non_neg_integer()

Return the total byte size for a tensor of the given shape and type.

device_info()

@spec device_info() :: map()

Returns information about the compute device/backend.

Currently returns CPU-based backend info. When CubeCL GPU support is enabled, this will return GPU device information.

from_binary(binary, shape, type)

@spec from_binary(binary(), tuple(), tuple()) :: Nx.Tensor.t()

Create a tensor from a binary with the given shape and type.

supported_types()

@spec supported_types() :: [tuple()]

Returns the list of supported tensor types.

to_binary(tensor)

@spec to_binary(Nx.Tensor.t()) :: binary()

Read a tensor's data into a binary.

type_size(arg)

@spec type_size(tuple()) :: pos_integer()

Return the size in bytes of a single element for the given Nx type.

version()

@spec version() :: String.t()

Returns the version of ExCubecl.