Skip to content
class

DataBuffer

DataBuffer

Flat untyped CPU buffer descriptor produced by the Allocator.

Shared with CpuStorage so that the allocator's StoragePtr abstraction can be threaded through tensor construction without an extra copy or wrapper layer. Treat as an allocator-layer view of the same underlying memory; CpuStorage is the tensor-layer wrapper.

See Also

CpuStorage — tensor-layer wrapper around the same bytes.

Attributes

ptrstd::shared_ptr<std::byte[]>
Owning pointer to the byte buffer. Shared between every descriptor and tensor that references the same allocation.
nbytesstd::size_t
Allocated capacity in bytes.
dtypeDtype
Element type stored in the buffer. Default Dtype::F32.
versionstd::shared_ptr<VersionCounter>
Atomic mutation counter shared with every alias of this allocation.

Methods

2
fnconst

bump_version

void bump_version()

Atomically increments the version counter.

Uses memory_order_relaxed because version bumps are sequenced by the surrounding op — autograd only inspects the counter at well-defined synchronisation points (forward save / backward replay).

fnconst

get_version

→std::uint64_t
int get_version()

Atomically reads the current version counter value.

Returns

std::uint64_t

Monotonically non-decreasing snapshot of mutation count.