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

tofile(file)[source]¶

Write the tensor to a binary file.

Added in version 0.1.11.

Parameters:

file – A file-like object with a write method that accepts bytes, or has an fileno() method.

Return type:

None