Reshapes an array to a new shape without changing the underlying data.
The elements keep their column-major order, exactly as base R's dim<-
does.
Arguments
- x
(
arrayish)
One input. Can be any data type. An R value materializes at its default data type.- shape
(
integer())
Target shape. Must have the same number of elements asx. At most one entry may be-1, in which case its extent is inferred from the remaining entries and the number of elements ofx.
Value
(arrayish)
Has the same data type as the input and the given shape.
StableHLO
Lowers to hlo_reshape(), specified under
reshape.
The lowering wraps it in two hlo_transpose() calls that reverse every
axis, which is what turns stablehlo's row-major reshape into a column-major
one; each is skipped where that side has at most one axis.