Cast

Description

Converts the input data type to the specified data type.

Input

x: tensor to be forcibly converted. The data type can be float, float16, int8, int32, int64, uint8 or bool.

Property

to (mandatory): int32, specifying the data type to which the elements of the input tensor are converted. It must be one of the DataType enumerations in TensorProto.

Output

y: output tensor. The data type is specified by the to parameter. The data type can be bool, float16, float, int8, int16, or int32.

Constraints

  • When the data type is converted from float16 to int16, if the input data contains inf, the inf is converted to the maximum value of int16. If the input data contains -inf, -inf is converted to the minimum value of INT16.
  • When the data type is converted from int32 to int8, it can only guarantee that the input data has no precision errors within the range of (-2048, 1920).

ONNX Opset Support

Opset v8/v9/v10/v11/v12/v13/v14/v15/v16/v17/v18