Python wrappers
Public Python APIs implemented by this engine symbol.Reinterpret a tensor under a new shape (no data copy).
The total element count must be preserved. Exactly one entry of
new_shape may be -1, in which case that dimension is inferred from
the remaining sizes. The input must be contiguous; pass non-contiguous
inputs through contiguous_op first.
Shape
, after resolving any
-1 entry.
See Also
flatten_op, squeeze_op, contiguous_op.
Parameters
aTensorImplPtrInput tensor. Must be C-contiguous.
new_shapevector<int64_t>Target shape. At most one entry may be
-1. All other entries must be non-negative. Since Shape == vector<int64_t>, this overload also accepts Shape directly.Returns
TensorImplPtrA view tensor with shape new_shape (with -1 resolved) sharing storage with a.
Raises
ShapeMismatchIf element counts do not match, multiple
-1 entries are given, or the input is non-contiguous.Examples
reshape_op(t_2x3, {6}) flattens a 2x3 to a 1-D length-6 view.
reshape_op(t_2x6, {-1, 3}) infers the first dim as 4.