Function reshape

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

Operation reshape (
  Operation input,
  ulong[] shape,
  string mod = __MODULE__,
  ulong line = cast(ulong)__LINE__
);

Parameters

NameDescription
input The operation to be reshaped.
shape The new shape.

Returns

The new Operation.

Example

import dopt.core : evaluate;

auto r1 = float32([2, 2], [1.0f, 2.0f, 3.0f, 4.0f]).reshape([1, 4]);

assert(r1.shape == [1, 4]);
assert(r1.evaluate().as!float == [1.0f, 2.0f, 3.0f, 4.0f]);