Skip to main contentIBM Quantum Documentation Mirror

TensorModel

pydantic model TensorModel

GitHub

Bases: BaseModel

Model of tensor data.

data

field

Type: str [Required]

Base-64-encoded data in litte endian format.

Bool arrays are bitpacked, other types are IEEE753. Everything is little-endian. Tensors are C-ordering.

Validated by

  • check_sizes

dtype

field

Type: Literal['f64', 'bool', 'u8', 'c128'] [Required]

The data type of the tensor.

Validated by

  • check_sizes

shape

field

Type: list[int] [Required]

The shape of the tensor.

Validated by

  • check_sizes

check_sizes

validator check_sizes

GitHub

Cross-validate that all sizes are consistent.

from_numpy

classmethod from_numpy(array)

GitHub

Instantiate from a NumPy array.

Parameters

array (ndarray)

to_numpy

to_numpy()

GitHub

Convert to a NumPy Array.

Return type

ndarray