mindspore.ops.DataFormatVecPermute
- class mindspore.ops.DataFormatVecPermute(src_format='NHWC', dst_format='NCHW')[source]
Permute input tensor from src_format to dst_format.
- Parameters
- Inputs:
input_x (Tensor) - A Tensor of shape (4, ) or (4, 2) in source data format. Only supports int32 and int64.
- Outputs:
Tensor, has the same data type and shape as the input_x.
- Raises
TypeError – If input_x is not a Tensor.
TypeError – If dtype of input_x is neither int32 nor int64.
ValueError – If src_format or dst_format is not a str in [‘NHWC’, ‘NCHW’].
ValueError – If input_x shape is not (4, ) or (4, 2).
- Supported Platforms:
GPU
CPU
Examples
>>> class Net(nn.Cell): ... def __init__(self, src_format="NHWC", dst_format="NCHW"): ... super().__init__() ... self.op = ops.DataFormatVecPermute(src_format, dst_format) ... def construct(self, x): ... return self.op(x) ... >>> net = Net() >>> x = Tensor(np.array([1, 2, 3, 4]).astype(np.int32)) >>> output = net(x) >>> print(output) [1 4 2 3]