TensorProtocol¶
- class onnx_ir.TensorProtocol(*args, **kwargs)¶
Concrete tensor backed by data.
The protocol does not specify how the data is stored. That data is exposed through the
raw
attribute for examination, but accessingraw
is typically not needed.To use the tensor as a numpy array, call
numpy()
. To convert the tensor to a byte string for serialization, calltobytes()
.It is recommended to check the size of the tensor first before accessing the underlying data, because accessing the data may be expensive and incur IO overhead.
- shape¶
The shape of the tensor.
- Type:
ShapeProtocol
- dtype¶
The data type of the elements of the tensor. It is an
ir.DataType
enum.- Type:
_enums.DataType
- raw¶
The raw data behind this tensor. It can be anything.
- Type:
Any
- size¶
The number of elements in the tensor.
- nbytes¶
The number of bytes in the tensor.
- tobytes() bytes [source]¶
Return the tensor as a byte string conformed to the ONNX specification, in little endian.
- shape: ShapeProtocol¶
- dtype: _enums.DataType¶
- raw: Any¶