ClikaRT::spec::Dim
struct
Header: ClikaRT/graph/input_specs.h
A dynamic dimension as a first-class object: declare it once, use it everywhere it appears, and every use refers to the SAME size.
Two ways a Dim ties dims together:
- By name. Models carry named dynamic dims (
spec::TensorSpec::dim_names; ONNX calls themdim_param, e.g. "batch_size" on every input): the same name means the same size wherever it appears.Dim("batch_size")names that dimension. - By identity. A default-constructed
Dim()is anonymous but carries identity; every copy of it refers to the same dimension, so passing oneDimobject into severaladd_inputshapes ties those dims; the model assigns it a systematic name ("dim_0", "dim_1", …).
A Dim may also carry a value: a single pin, or a min/opt/max range (the opt value is what a compiled graph is specialized to; min/max are validated). Valueless (declaration-only) is min==opt==max==kUnset.
Dim batch("batch_size"); // named, unpinned
specs.bind(Dim("batch_size", 1)); // pin it at compile
specs.bind(Dim("sequence_length", 1, 128, 512)); // a range
Member functions
Dim()
Dim()
Anonymous with identity: copies of this object denote ONE dimension.
Declared in ClikaRT/graph/input_specs.h, line 53
Dim(string_view)
explicit Dim(std::string_view dim_name)
A named dynamic dim, unpinned: a declaration to bind or pin later.
Declared in ClikaRT/graph/input_specs.h, line 55
Dim(string_view, int64_t)
Dim(std::string_view dim_name, std::int64_t value)
A named dim pinned to a single value (min == opt == max).
Declared in ClikaRT/graph/input_specs.h, line 57
Dim(string_view, int64_t, int64_t, int64_t)
Dim(
std::string_view dim_name,
std::int64_t min_value,
std::int64_t opt_value,
std::int64_t max_value
)
A named dim carrying a min_value / opt_value / max_value range.
Declared in ClikaRT/graph/input_specs.h, line 60
has_value()
bool has_value() const noexcept
True when the dim carries a value (its opt bound is set).
Declared in ClikaRT/graph/input_specs.h, line 65
pinned(int64_t)
Dim pinned(std::int64_t value) const
A copy of this dimension carrying a pinned value / range, the binding form of a declared Dim, so one object serves declaration AND compile-time pinning: specs.bind(batch.pinned(2)).
Declared in ClikaRT/graph/input_specs.h, line 70
pinned(int64_t, int64_t, int64_t)
Dim pinned(
std::int64_t min_value,
std::int64_t opt_value,
std::int64_t max_value
) const
The range form of pinned: a copy carrying min_value / opt_value / max_value.
Declared in ClikaRT/graph/input_specs.h, line 76
token()
const void* token() const noexcept
The identity token of an anonymous Dim (null for a named one): how a model recognizes the same anonymous dimension across uses.
Declared in ClikaRT/graph/input_specs.h, line 86
Data members
name
std::string name
the dynamic dim's name (empty = anonymous with identity).
Declared in ClikaRT/graph/input_specs.h, line 47
min
std::int64_t min = kUnset
smallest extent (kUnset = unset).
Declared in ClikaRT/graph/input_specs.h, line 48
opt
std::int64_t opt = kUnset
the extent a compiled graph specializes to.
Declared in ClikaRT/graph/input_specs.h, line 49
max
std::int64_t max = kUnset
largest extent (kUnset = unset).
Declared in ClikaRT/graph/input_specs.h, line 50
Static data members
kUnset
static std::int64_t kUnset = -1
sentinel: this bound is not set.
Declared in ClikaRT/graph/input_specs.h, line 45