CastLike - version 24#

This page documents version 24 of operator CastLike. See CastLike for the latest version (since version 25).

  • Domain: ai.onnx

  • Since version: 24

The operator casts the elements of a given input tensor (the first input) to the same data type as the elements of the second input tensor. See documentation of the Cast operator for further details.

Inputs

  • input (T1): Input tensor to be cast.

  • target_type (T2): The (first) input tensor will be cast to produce a tensor of the same type as this (second input) tensor.

Outputs

  • output (T2): Output tensor produced by casting the first input tensor to have the same type as the second input tensor.

Attributes

  • round_mode (string): Rounding mode for conversion to float8e8m0. It only applies to casting to float8e8m0 and is up by default. up: round to nearest value away from zero, down: round to nearest value towards zero, nearest: round to nearest value and ties round up. Please refer to operator Cast description for further details.

  • saturate (int): The parameter defines how the conversion behaves if an input value is out of range of the destination type. It only applies for float 8 conversion (float8e4m3fn, float8e4m3fnuz, float8e5m2, float8e5m2fnuz). It is true by default. Please refer to operator Cast description for further details.

Type Constraints

  • T1: Constrain input types. Casting from complex is not supported. Allowed types: tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float4e2m1), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(float8e8m0), tensor(int16), tensor(int32), tensor(int4), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint4), tensor(uint64), tensor(uint8).

  • T2: Constrain output types. Casting to complex is not supported. Allowed types: tensor(bfloat16), tensor(bool), tensor(double), tensor(float), tensor(float16), tensor(float4e2m1), tensor(float8e4m3fn), tensor(float8e4m3fnuz), tensor(float8e5m2), tensor(float8e5m2fnuz), tensor(float8e8m0), tensor(int16), tensor(int32), tensor(int4), tensor(int64), tensor(int8), tensor(string), tensor(uint16), tensor(uint32), tensor(uint4), tensor(uint64), tensor(uint8).

Differences with previous version (23)#

SchemaDiff: CastLike (domain 'ai.onnx')

  • old version: 23

  • new version: 24

  • breaking: no

Attributes:

  • added ‘round_mode’: type=STRING; required=False; default=up

Type constraints:

  • changed ‘T1’: added types: [‘tensor(float8e8m0)’]

  • changed ‘T2’: added types: [‘tensor(float8e8m0)’]