Shortcuts

JitScalarType

class torch.onnx.JitScalarType(value)

Scalar types defined in torch.

Use JitScalarType to convert from torch and JIT scalar types to ONNX scalar types.

Examples::
>>> JitScalarType.from_name("Float").onnx_type()
TensorProtoDataType.FLOAT
dtype()[source]

Convert a ScalarType to a torch dtype.

Return type:

dtype

classmethod from_dtype(dtype)[source]

Convert a torch dtype to ScalarType.

Return type:

JitScalarType

classmethod from_name(name)[source]

Convert a JIT scalar type or torch type name to ScalarType.

Parameters:

name (Optional[Union[typing_extensions.Literal[Byte, Char, Double, Float, Half, Int, Long, Short, Bool, ComplexHalf, ComplexFloat, ComplexDouble, QInt8, QUInt8, QInt32, BFloat16, Undefined], typing_extensions.Literal[bool, uint8_t, int8_t, double, float, half, int, int64_t, int16_t, complex32, complex64, complex128, qint8, quint8, qint32, bfloat16], str]]) – JIT scalar type name (Byte) or torch type name (uint8_t).

Returns:

ScalarType.

Raises:

ValueError – if name is not a valid scalar type name or if it is None.

Return type:

JitScalarType

onnx_compatible()[source]

Return whether this ScalarType is compatible with ONNX.

Return type:

bool

onnx_type()[source]

Convert a ScalarType to an ONNX data type.

Return type:

TensorProtoDataType

scalar_name()[source]

Convert a ScalarType to a JIT scalar type name.

Return type:

typing_extensions.Literal[Byte, Char, Double, Float, Half, Int, Long, Short, Bool, ComplexHalf, ComplexFloat, ComplexDouble, QInt8, QUInt8, QInt32, BFloat16, Undefined]

torch_name()[source]

Convert a ScalarType to a torch type name.

Return type:

typing_extensions.Literal[bool, uint8_t, int8_t, double, float, half, int, int64_t, int16_t, complex32, complex64, complex128, qint8, quint8, qint32, bfloat16]

Docs

Access comprehensive developer documentation for PyTorch

View Docs

Tutorials

Get in-depth tutorials for beginners and advanced developers

View Tutorials

Resources

Find development resources and get your questions answered

View Resources