mindspore.ops.DataFormatDimMap

class mindspore.ops.DataFormatDimMap(*args, **kwargs)[source]

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

Parameters
  • src_format (string) – An optional value for source data format. Default: ‘NHWC’.

  • dst_format (string) – An optional value for destination data format. Default: ‘NCHW’.

Inputs:
  • input_x (Tensor) - A Tensor with each element as a dimension index in source data format. The suggested values is in the range [-4, 4). It’s type is int32.

Outputs:

Tensor, has the same type 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

Examples

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