reshape

Allows one to cast an operation to a different shape with the same volume.

reshape
(
,
size_t[] shape
,
string mod = __MODULE__
,
size_t line = __LINE__
)

Parameters

input
Type: Operation

The operation to be reshaped.

shape
Type: size_t[]

The new shape.

Return Value

Type: Operation

The new Operation.

Examples

1 import dopt.core : evaluate;
2 
3 auto r1 = float32([2, 2], [1.0f, 2.0f, 3.0f, 4.0f]).reshape([1, 4]);
4 
5 assert(r1.shape == [1, 4]);
6 assert(r1.evaluate().as!float == [1.0f, 2.0f, 3.0f, 4.0f]);

Meta