StringTensor¶

class onnx_ir.StringTensor(value, *, shape=None, name=None, doc_string=None, metadata_props=None)¶

Multidimensional array of strings (as binary data to match the string_data field in TensorProto).

Parameters:
  • value (Sequence[bytes] | npt.NDArray[np.bytes_])

  • shape (Shape | None)

  • name (str | None)

  • doc_string (str | None)

  • metadata_props (dict[str, str] | None)

display(*, page=False)¶

Pretty print the object.

Parameters:

page (bool) – Whether to page the output.

Return type:

None

property doc_string: str | None¶

The documentation string.

property dtype: DataType¶

The data type of the tensor. Immutable.

property meta: MetadataStore¶

The metadata store for intermediate analysis.

Write to the metadata_props if you would like the metadata to be serialized to the ONNX proto.

property metadata_props: dict[str, str]¶
property name: str | None¶

The name of the tensor.

property nbytes: int¶

The number of bytes in the tensor.

numpy()[source]¶

Return the tensor as a numpy array.

Return type:

npt.NDArray[np.bytes_]

property raw: Sequence[bytes] | npt.NDArray[np.bytes_]¶

Backing data of the tensor. Immutable.

property shape: Shape¶

The shape of the tensor. Immutable.

property size: int¶

The number of elements in the tensor.

string_data()[source]¶

Return the string data of the tensor.

Return type:

Sequence[bytes]

tobytes()[source]¶

Return the tensor as a byte string conformed to the ONNX specification, in little endian.

Return type:

bytes