TensorSpec
One input or output slot of a graph: its name, dtype and dims. A dims entry of -1 (TensorSpec.kDynamicDim) is dynamic; a dim_names entry names a dynamic dim so slots sharing the name share the size.
dim_names (property)
Optional per-dim labels aligned with dims; empty when unnamed.
dims (property)
Per-dim sizes; -1 marks a dynamic dim.
dtype (property)
The element dtype (clika_runtime.float32 and kin); assignable from a dtype object or its name.
is_dynamic (property)
True when any dim is dynamic.
kDynamicDim (property)
(arg: object, /) -> int
name (property)
The slot name, the binding key.
optional (property)
True when the slot may be absent in a request.
__init__
__init____init__(self) -> None
init(self) -> None init(self, name: str, dtype: object, dims: collections.abc.Sequence[int], optional: bool = False, dim_names: collections.abc.Sequence[str] = []) -> None
Overloaded function.
-
__init__(self) -> None -
__init__(self, name: str, dtype: object, dims: collections.abc.Sequence[int], optional: bool = False, dim_names: collections.abc.Sequence[str] = []) -> None
TensorSpec(name, dtype, dims, optional=False, dim_names=())
An input/output slot: dims entries of -1 are dynamic; a dim_names entry names a dynamic dim so slots sharing the name share the size. dtype is a dtype object (clika_runtime.float32) or its name.
dim_is_dynamic
dim_is_dynamicdim_is_dynamic(self, i: int) -> bool
dim_is_dynamic(self, i: int) -> bool
dim_is_dynamic(i) -> bool
Whether dim i is dynamic (False past the rank).
dim_name
dim_namedim_name(self, i: int) -> str
dim_name(self, i: int) -> str
dim_name(i) -> str
The label of dim i, or '' when unnamed.
from_tensor
from_tensorfrom_tensor(tensor: clika_runtime._core.Tensor, name: str = '') -> clika_runtime._core.TensorSpec
from_tensor(tensor: clika_runtime._core.Tensor, name: str = '') -> clika_runtime._core.TensorSpec
from_tensor(tensor, name='') -> TensorSpec
The slot a tensor fills: its dtype and its dims as fixed sizes (waits for a pending shape).
from_tensors
from_tensorsfrom_tensors(tensors: collections.abc.Sequence[clika_runtime._core.Tensor]) -> list[clika_runtime._core.TensorSpec]
from_tensors(tensors: collections.abc.Sequence[clika_runtime._core.Tensor]) -> list[clika_runtime._core.TensorSpec]
from_tensors(tensors) -> list[TensorSpec]
One slot per tensor, in order, each named positionally.
merge_from
merge_frommerge_from(self, other: clika_runtime._core.TensorSpec) -> None
merge_from(self, other: clika_runtime._core.TensorSpec) -> None
merge_from(other) -> None
Widen this slot, in place, by another observation of the same slot. A dim dynamic on either side stays dynamic, extents that differ become dynamic, and a rank clash makes every dim dynamic at the larger rank, so merging TensorSpec.from_tensor(b) into TensorSpec.from_tensor(a) marks the dims the two examples disagree on. A dim name is kept where the two sides agree or one is unnamed, and dropped where they conflict. An empty name takes other.name, and optional is kept. Raises InvalidArgumentError when the dtypes differ.