apply method

  1. @override
TensorBuffer apply(
  1. TensorBuffer input
)
override

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);
}