pub struct ShapeData {
pub dtype: DataType,
pub dims: Vec<usize>,
pub elems: Vec<DimExpr>,
}Expand description
The known element values of a rank-0 or rank-1 integer tensor flowing through a shape-computation subgraph.
Fields§
§dtype: DataTypeThe integer element type (Int64/Int32, or Bool for masks).
dims: Vec<usize>Static dimensions. Empty == rank-0 scalar; [n] == rank-1 vector.
elems: Vec<DimExpr>Row-major elements. Length is 1 for a scalar, dims[0] for a vector.
Implementations§
Source§impl ShapeData
impl ShapeData
Sourcepub fn within_bounds(&self) -> bool
pub fn within_bounds(&self) -> bool
Whether the element count is within MAX_SHAPE_DATA_ELEMS.
Sourcepub fn as_shape(&self) -> Vec<DimExpr>
pub fn as_shape(&self) -> Vec<DimExpr>
This value’s contents interpreted as a shape (each element is a dim).
Used by Reshape/Expand/ConstantOfShape to turn a resolved shape
vector into the output shape.
Sourcepub fn from_tensor(dtype: DataType, dims: &[usize], data: &[u8]) -> Option<Self>
pub fn from_tensor(dtype: DataType, dims: &[usize], data: &[u8]) -> Option<Self>
Extract shape-data from a concrete constant tensor, if it is a small
(rank ≤ 1, within MAX_SHAPE_DATA_ELEMS) integer or boolean tensor.
Non-integer tensors, higher-rank tensors, and over-large tensors are not
tracked (returns None) — only the shape-computation operands matter.