reshape function
Reshapes a variable.
Args:
- x: A variable.
- shape: A vector, the shape of the target variable.
- original_format: A enum, only NCHW/NHWC is allowed, NC4HW4 is not allowed, as it provides additional information(x comes from NCHW or NHWC) When x is NC4HW4.
Returns:
- output: A variable with the same type as
x.
Implementation
VARP reshape(VARP x, List<int> shape, {DimensionFormat format = DimensionFormat.NCHW}) {
final (shapePtr, shapeSize) = shape.toNativeArrayI32();
final rval = VARP.fromPointer(
C.mnn_expr_Reshape(
x.ptr,
shapePtr.cast(),
shapeSize,
format.value,
),
);
calloc.free(shapePtr);
return rval;
}