mindspore.ops.DataFormatDimMap

class mindspore.ops.DataFormatDimMap(src_format='NHWC', dst_format='NCHW')[source]

Returns the dimension index in the destination data format given in the source data format.

Parameters
  • src_format (str) – An optional value for source data format. The format can be ‘NHWC’ and ‘NCHW’. Default: ‘NHWC’.

  • dst_format (str) – An optional value for destination data format. The format can be ‘NHWC’ and ‘NCHW’. Default: ‘NCHW’.

Inputs:
  • input_x (Tensor) - A Tensor, each element is used as a dimension index of the source data format. The suggested values are in the range [-4, 4). Only supports int32.

Outputs:

Tensor, Return the dimension index in the given target data format, has the same data type and shape as the input_x.

Raises
  • TypeError – If src_format or dst_format is not a str.

  • TypeError – If input_x is not a Tensor whose dtype is not int32.

Supported Platforms:

Ascend GPU CPU

Examples

>>> input_x = Tensor([0, 1, 2, 3], mindspore.int32)
>>> dfdm = ops.DataFormatDimMap()
>>> output = dfdm(input_x)
>>> print(output)
[0 3 1 2]