mindspore.ops.scalar_cast

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

The interface is deprecated from version 2.3 and will be removed in a future version, please use int(x) or float(x) instead.

Casts the input scalar to another type.

Parameters
  • input_x (scalar) – The input scalar.

  • input_y (mindspore.dtype) – The type to be cast. Only constant value is allowed. The value should only be mindspore.int64, mindspore.float64, or mindspore.bool_.

Returns

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

Raises

ValueError – if input_y's value is invalid.

Supported Platforms:

Deprecated

Examples

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