Skip to main content

ClikaRT::io::TensorsContainer

class

Header: ClikaRT/io/tensors_container.h

A lazily-materializing view of a checkpoint's tensors. Move-only: the container caches each materialized tensor so repeated gets share one storage, and that cache must have a single owner.

Nested types

NameDescription
EntryOne parsed (never materialized) checkpoint entry, the header-only metadata a placement or config probe reads with no payload IO.

Member functions

TensorsContainer()

TensorsContainer()

An empty container (no entries).

Declared in ClikaRT/io/tensors_container.h, line 56

TensorsContainer(TensorsContainer)

TensorsContainer(TensorsContainer&& other) noexcept

Move: transfers the container handle.

Declared in ClikaRT/io/tensors_container.h, line 59

operator=(TensorsContainer)

TensorsContainer& operator=(TensorsContainer&& other) noexcept

Move-assign: transfers the container handle.

Declared in ClikaRT/io/tensors_container.h, line 61

TensorsContainer(TensorsContainer)

TensorsContainer(const TensorsContainer&) =delete

Declared in ClikaRT/io/tensors_container.h, line 62

operator=(TensorsContainer)

TensorsContainer& operator=(const TensorsContainer&) =delete

Declared in ClikaRT/io/tensors_container.h, line 63

~TensorsContainer()

~TensorsContainer()

Releases the container (open file mappings close with the last user).

Declared in ClikaRT/io/tensors_container.h, line 65

get()

Tensor get(std::string_view name)

Materialize (or return the cached) tensor under name. Raises ClikaRT::Error for an unknown name or a failed materialization.

Declared in ClikaRT/io/tensors_container.h, line 70

load_all()

NamedTensors load_all()

Materialize EVERY entry into an eager NamedTensors map.

Declared in ClikaRT/io/tensors_container.h, line 74

prefetch()

void prefetch(ClikaRT::Span<const std::string> names, StreamOrDevice where = {})

Warm entries ahead of use: read-ahead on their file ranges; an evicted materialized tensor restores now, asynchronously on where when set (a stream the restore rides, program-ordered with the caller's work there; a device picks its default stream), else on the runtime's dedicated per-device residency stream. Unknown names raise ClikaRT::Error. names is read during the call, not retained.

Declared in ClikaRT/io/tensors_container.h, line 83

load_into()

void load_into(
    std::string_view name,
    Tensor& dst,
    StreamOrDevice where = {}
)

Write name's payload bytes INTO the caller's dst buffer; no allocation, no file-backing stamped: the buffer stays the caller's (the persistent double-buffer shape a streaming loop overwrites each step). dst must match the entry's shape and dtype; a cross-device dst receives the bytes through the transfer path, riding where (unset ⇒ dst's own stream). Raises ClikaRT::Error for an unknown name or a mismatched destination.

Declared in ClikaRT/io/tensors_container.h, line 93

evict()

void evict(std::string_view name)

Drop the container's cached handle for name; after an evict the bound consumer owns the storage alone, and a later get of the same name materializes FRESH storage (identity across an evict is not preserved). Residency follows the entry's placement and intent: a host-resident file-backed entry releases its memory back to the file (a consumer that bound it sees its next use restore transparently), and an entry loaded under the sticky disk-backed policy releases wherever it lives; a device-resident entry loaded WITHOUT the sticky policy keeps its device memory; the caller that bound it keeps the residency it paid to establish, and releasing device residency belongs to the residency verbs (nn::Module::evict_weights). A name that was never materialized is a no-op; an unknown name raises ClikaRT::Error. Requires that no caller still holds a raw data pointer into a released entry.

Declared in ClikaRT/io/tensors_container.h, line 110

evict_all()

void evict_all()

Evict every materialized tensor under evict's own per-entry rule (first failure aborts and raises).

Declared in ClikaRT/io/tensors_container.h, line 115

release()

void release(std::string_view name)

Drop the container's cached handle for name (the entry stays; a later get re-materializes). No-op when nothing is cached.

Declared in ClikaRT/io/tensors_container.h, line 119

contains()

bool contains(std::string_view name) const

True if the checkpoint has an entry under name.

Declared in ClikaRT/io/tensors_container.h, line 122

size()

std::size_t size() const

Number of entries.

Declared in ClikaRT/io/tensors_container.h, line 124

total_bytes()

std::size_t total_bytes() const

Sum of every entry's on-disk payload bytes, the checkpoint's total footprint, known without materializing anything.

Declared in ClikaRT/io/tensors_container.h, line 127

entry_bytes()

std::uint64_t entry_bytes(std::string_view name) const

One entry's on-disk payload bytes (0 for an unknown name), the per-tensor feed a placement scheduler sums into per-unit (e.g. per-layer) budgets against a LoadPlan's resident_byte_budget. A composed (adapted) entry reports the sum of its parts' bytes.

Declared in ClikaRT/io/tensors_container.h, line 132

names()

std::vector<std::string> names() const

All entry names, sorted.

Declared in ClikaRT/io/tensors_container.h, line 134

entry()

std::optional<Entry> entry(std::string_view name) const

The parsed metadata behind name: introspection with NO materialization and no payload IO. std::nullopt for an unknown name AND for a composed (adapted) name: a composed value is derived, so it has no single parsed entry; probe its existence via contains/names and its cost via entry_bytes.

Declared in ClikaRT/io/tensors_container.h, line 160