mindspore.ops.scalar_cast

mindspore.ops.scalar_cast(input_x, input_y)[源代码]

Casts the input scalar to another type.

Parameters
  • input_x (scalar) – The input scalar. Only constant value is allowed.

  • input_y (mindspore.dtype) – The type to be cast. Only constant value is allowed.

Returns

Scalar. The type is the same as the python type corresponding to input_y.

Raises

TypeError – If neither input_x nor input_y is a constant value.

Supported Platforms:

Ascend GPU CPU

Examples

>>> output = ops.scalar_cast(255.0, mindspore.int32)
>>> print(output)
255