TorchTensor¶

class onnx_ir.tensor_adapters.TorchTensor(tensor, name=None, doc_string=None)[source]¶
Parameters:
numpy()[source]¶

Return the tensor as a numpy array.

When the data type is not supported by numpy, the dtypes from the ml_dtype package are used. The values can be reinterpreted as bit representations using the .view() method.

Return type:

ndarray[tuple[int, …], dtype[_ScalarType_co]]

tobytes()[source]¶

Returns the value as bytes encoded in little endian.

Override this method for more efficient serialization when the raw value is not a numpy array.

Return type:

bytes