MindSpore Implicit Type Conversion Operator List

Linux Ascend GPU CPU Model Development Beginner Intermediate Expert

View Source On Gitee

Implicit Type Conversion

conversion rules

  • Scalar and Tensor operations: during operation, the scalar is automatically converted to Tensor, and the data type is consistent with the Tensor data type involved in the operation; when Tensor is a bool data type and the scalar is int or float, both the scalar and Tensor are converted to the Tensor with the data type of int32 or float32.

  • Tensor operation of different data types: the priority of data type is bool < uint8 < int8 < int16 < int32 < int64 < float16 < float32 < float64, during the operation, first determine the data type with the relatively highest priority among the Tensors involved in the operation, and then convert the low priority data type Tensor to the relatively highest priority data type; when the Tensor of int8 and uint8 data types are operated, they are converted to int16 Tensor.

  • Data type conversion of Parameter is not supported: If inferred according to the conversion rules, RuntimeError exception will be thrown when the data type conversion of Parameter defined in the network is required.

data types involved in conversion

  • bool

  • int8

  • uint8

  • int16

  • int32

  • int64

  • float16

  • float32

  • float64

support ops

op name

mindspore.ops.Assign

mindspore.ops.AssignSub

mindspore.ops.ApplyMomentum

mindspore.ops.FusedSparseAdam

mindspore.ops.FusedSparseLazyAdam

mindspore.ops.FusedSparseFtrl

mindspore.ops.FusedSparseProximalAdagrad

mindspore.ops.ApplyAdaMax

mindspore.ops.ApplyAdadelta

mindspore.ops.ApplyAdagrad

mindspore.ops.ApplyAdagradV2

mindspore.ops.SparseApplyAdagrad

mindspore.ops.SparseApplyAdagradV2

mindspore.ops.ApplyProximalAdagrad

mindspore.ops.SparseApplyProximalAdagrad

mindspore.ops.ApplyAddSign

mindspore.ops.ApplyPowerSign

mindspore.ops.ApplyGradientDescent

mindspore.ops.ApplyProximalGradientDescent

mindspore.ops.SparseApplyFtrl

mindspore.ops.SparseApplyFtrlV2

mindspore.ops.BitwiseAnd

mindspore.ops.BitwiseOr

mindspore.ops.BitwiseXor

mindspore.ops.TensorAdd

mindspore.ops.Sub

mindspore.ops.Mul

mindspore.ops.Pow

mindspore.ops.Minimum

mindspore.ops.Maximum

mindspore.ops.RealDiv

mindspore.ops.Div

mindspore.ops.DivNoNan

mindspore.ops.FloorDiv

mindspore.ops.TruncateDiv

mindspore.ops.TruncateMod

mindspore.ops.Mod

mindspore.ops.FloorMod

mindspore.ops.Atan2

mindspore.ops.SquaredDifference

mindspore.ops.Xdivy

mindspore.ops.Xlogy

mindspore.ops.Equal

mindspore.ops.ApproximateEqual

mindspore.ops.NotEqual

mindspore.ops.Greater

mindspore.ops.GreaterEqual

mindspore.ops.Less

mindspore.ops.LessEqual

mindspore.ops.LogicalAnd

mindspore.ops.LogicalOr

mindspore.ops.ScatterNdUpdate

mindspore.ops.ScatterNdAdd

mindspore.ops.ScatterNdSub

mindspore.ops.ScatterNonAliasingAdd

mindspore.ops.ScatterUpdate

mindspore.ops.ScatterMax

mindspore.ops.ScatterMin

mindspore.ops.ScatterAdd

mindspore.ops.ScatterSub

mindspore.ops.ScatterMul

mindspore.ops.ScatterDiv