apply method
Applies this transform to input and returns the result.
Implementation
@override
TensorBuffer apply(TensorBuffer input) {
final contiguous = ensureContiguous(input);
final shape = contiguous.shape;
if (shape.length != 3 && shape.length != 4) {
throw ShapeMismatchException(
actual: shape,
message: 'ToImageOp expects CHW or NCHW input',
);
}
return shape.length == 3
? _convertChwToHwc(contiguous)
: _convertNchwToNhwc(contiguous);
}