mindspore.ops.scalar_cast

View Source On Gitee
mindspore.ops.scalar_cast(input_x, input_y)[source]

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

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