Pure metadata descriptor for a tensor — bundles shape, stride, dtype, and device without owning any Storage.
Used wherever the engine needs to reason about a tensor's geometry
without touching its data: broadcast resolution, view / reshape
planning, output-shape inference for op dispatch, and signature
hashing for kernel caches. Cheap to copy (a handful of small
std::vector handles plus two enum ints), so callers pass it by
value freely.
Strides follow the BYTE-OFFSET convention — stride[i] is the
byte delta required to step one element along axis i. A
TensorMeta is considered contiguous when its strides match
contiguous_stride(shape, dtype_size(dtype)).
See Also
lucid::core::TensorMeta — engine-internal twin embedded in
TensorImpl.
contiguous_stride — canonical stride producer.
Attributes
shapeShapestrideStrideshape.size() for the layout to be considered well-formed; the default constructor leaves both vectors empty.dtypeDtypeDtype::F32.deviceDeviceDevice::CPU.Notes
All constructors are deliberately non-explicit to allow
aggregate-style initialisation in shape-inference helpers
(TensorMeta out{shape, dtype, device};).
Constructors
1TensorMeta
void TensorMeta()Default-construct an empty descriptor with zero-length shape and stride, dtype F32, and device CPU.
Useful as a placeholder when a TensorMeta will be filled
in by a later assignment (e.g. inside output-shape inference
loops that materialise one meta per op output).
Notes
The default-constructed instance describes a 0-dim scalar of
dtype F32 on the CPU; do not assume the shape vector has any
particular capacity reserved.
Methods
3Whether the stored stride matches the reference contiguous (row-major) stride for shape and dtype.
A tensor is C-contiguous when, for every axis i,
stride[i] == dtype_size(dtype) * prod(shape[i+1:]). This
method delegates the layout check to
contiguous_stride and compares the two Stride
vectors element-wise.
See Also
contiguous_stride — produces the reference stride.
lucid::core::TensorMeta::is_contiguous_for — engine-side
equivalent that takes an explicit elem_size.
Returns
booltrue if stride equals contiguous_stride(shape, dtype_size(dtype)), false otherwise.
Notes
Used by op kernels that require contiguous input to decide whether to materialise the descriptor via a copy before dispatch. A default-constructed (empty-shape, empty-stride) descriptor is contiguous by definition because both vectors compare equal.
Total bytes occupied by a contiguous layout of shape and dtype.
Equal to numel() * dtype_size(dtype); does NOT inspect
stride, so non-contiguous descriptors still report the
size of the equivalent contiguous tensor, not their actual
memory footprint in the parent storage.
Math
See Also
numel — logical element count.
dtype_size — width of a single element.
Returns
std::size_tNumber of bytes required to hold numel() elements of dtype.
Total number of logical elements described by shape.
Computed as the product of all dimension sizes; a 0-dim scalar
(empty shape) returns 1 by convention.
Math
See Also
shape_numel — the underlying element-count helper.
nbytes — contiguous byte count for the same shape/dtype.
Returns
std::size_tshape[0] * shape[1] * ... * shape[N-1], or 1 for a scalar.
Notes
Delegates to shape_numel from Shape.h, which
handles unresolved negative dimensions (returns 0) gracefully.