Skip to content
class

GpuStorage

GpuStorage

GPU tensor storage backed by an mlx::core::array lazy graph node.

The arr shared pointer keeps the MLX graph node alive for as long as this GpuStorage (and any TensorImpl that holds it) is in scope. All GPU-stream operations dispatch through MLX. Read the array's data pointer from the CPU only after it is evaluated (see TensorImpl::eval) — before that the buffer may not exist.

See Also

CpuStorage — CPU sibling variant. SharedStorage — unified-memory sibling variant.

Attributes

arrstd::shared_ptr<mlx::core::array>
Opaque handle to the MLX lazy graph node.
nbytesstd::size_t
Allocation capacity in bytes (logical — MLX may not have materialised the buffer yet).
dtypeDtype
Element type. Default Dtype::F32.
versionstd::shared_ptr<VersionCounter>
Shared mutation counter — same semantics as CpuStorage.

Methods

2
fnconst

bump_version

void bump_version()

Atomically increments the shared version counter.

fnconst

get_version

→std::uint64_t
int get_version()

Reads the current version counter value.

Returns

std::uint64_t

Monotonically non-decreasing snapshot of mutation count.