Function: toChannelsFirst()
toChannelsFirst(
src,dst):Tensor
Defined in: extensions/cv/ops/image.ts:179
Transposes an image tensor layout from HWC (Height, Width, Channel) to CHW (Channel, Height, Width).
Commonly required for PyTorch Edge models which expect channels-first inputs.
Parameters
src
The source image tensor in HWC layout. Expected shape [H, W, C]
(channels-last). Supports any numeric data type.
dst
The pre-allocated destination image tensor in CHW layout. Expected
shape [C, H, W] (channels-first) and the same data type as src.
Returns
The destination image tensor in CHW layout of shape [C, H, W] and
matching data type.
Throws
With code INVALID_ARGUMENT if tensor shapes,
layouts, or data types are invalid, RESOURCE_BUSY if a tensor is in use, or
RESOURCE_DISPOSED if either tensor was disposed.