Skip to main content

ClikaRT::spec::TensorSpec

struct

Header: ClikaRT/runtime/schema.h

A named, typed input/output slot, the library's ONE vocabulary for describing a tensor slot (a model input/output, a graph feed, a traced signature).

TensorSpec DESCRIBES a slot (name/dtype/dims as observed or declared); InputSpec (graph/input_specs.h) CONSTRAINS one; a compile/trace directive pinning an input's dynamic dims. Two types, two jobs. dims is the expected shape; an entry equal to kDynamicDim (-1) is resolved at run time. A dynamic dim may additionally carry a NAME in dim_names (an ONNX dim_param like "batch_size"); the same name on two slots declares the same size, so pinning it once (an InputSpec, a named-dim binding) resolves every slot that shares it. dim_names is either empty (no names) or dims-length with "" for unnamed dims. optional marks an input the model can run without.

Static member functions

from_tensor()

static TensorSpec from_tensor(const Tensor& tensor, std::string name = {})

The spec a live tensor observes: its dtype and concrete dims. A symbolic dim (a traced stand-in's dynamic dim) reads as kDynamicDim and keeps its declared name. Raises ClikaRT::Error on an undefined tensor.

Declared in ClikaRT/runtime/schema.h, line 94

from_tensors()

static std::vector<TensorSpec> from_tensors(const std::vector<Tensor>& tensors)

One spec per tensor, in order, names left empty; name the slots yourself, or let the consuming surface default them positionally.

Declared in ClikaRT/runtime/schema.h, line 100

Member functions

TensorSpec()

TensorSpec() =default

Declared in ClikaRT/runtime/schema.h, line 72

TensorSpec(string, DataType, vector<int64_t>, bool, …)

TensorSpec(
    std::string slot_name,
    DataType slot_dtype,
    std::vector<std::int64_t> slot_dims,
    bool is_optional = false,
    std::vector<std::string> slot_dim_names = {}
)

Declared in ClikaRT/runtime/schema.h, line 73

dim_is_dynamic()

bool dim_is_dynamic(std::size_t i) const

True when dim i is the dynamic sentinel (kDynamicDim).

Declared in ClikaRT/runtime/schema.h, line 82

dim_name()

std::string dim_name(std::size_t i) const

The dim's declared name, or "" (unnamed / out of range).

Declared in ClikaRT/runtime/schema.h, line 86

merge_from()

void merge_from(const TensorSpec& other)

Widen THIS spec by another observation of the same slot. Dims widen infallibly: a dim dynamic on either side stays dynamic, differing extents become dynamic, and a rank clash makes every dim dynamic at the max rank, so from_tensor(a) + merge_from(from_tensor(b)) infers the dynamic dims from example observations. A dim name is kept where the two sides agree or one is unnamed, dropped where they conflict; name is kept (adopted from other when empty), optional is kept. Raises ClikaRT::Error when the dtypes differ; two dtypes never merge.

Declared in ClikaRT/runtime/schema.h, line 114

Data members

name

std::string name

edge name, the binding key

Declared in ClikaRT/runtime/schema.h, line 66

dtype

element dtype

Declared in ClikaRT/runtime/schema.h, line 67

dims

std::vector<std::int64_t> dims

per-dim sizes; kDynamicDim marks a dynamic dim

Declared in ClikaRT/runtime/schema.h, line 68

dim_names

std::vector<std::string> dim_names

optional per-dim labels, aligned with dims

Declared in ClikaRT/runtime/schema.h, line 69

optional

bool optional = false

the edge may be absent in a request

Declared in ClikaRT/runtime/schema.h, line 70

Static data members

kDynamicDim

static std::int64_t kDynamicDim = -1

sentinel dim: the size resolves at bind/run time

Declared in ClikaRT/runtime/schema.h, line 64