npx.npx_numpy_tensors

EagerNumpyTensor

class onnx_array_api.npx.npx_numpy_tensors.EagerNumpyTensor(tensor: ndarray)[source]

Defines a value for a specific backend.

JitNumpyTensor

class onnx_array_api.npx.npx_numpy_tensors.JitNumpyTensor(tensor: ndarray)[source]

Defines a value for a specific backend.

NumpyTensor

class onnx_array_api.npx.npx_numpy_tensors.NumpyTensor(tensor: ndarray)[source]

Default backend based on onnx_array_api.reference.ExtendedReferenceEvaluator().

Parameters:
  • input_names – input names

  • onx – onnx model

class Evaluator(tensor_class: type, input_names: List[str], onx: ModelProto, f: Callable)[source]

Wraps class onnx_array_api.reference.ExtendedReferenceEvaluator to have a signature closer to python function.

Parameters:
  • tensor_class – class tensor such as NumpyTensor

  • input_names – input names

  • onx – onnx model

  • f – unused except in error messages

run(*inputs: List[NumpyTensor]) List[NumpyTensor][source]

Executes the function.

Parameters:

inputs – function inputs

Returns:

outputs

classmethod create_function(input_names: List[str], onx: ModelProto, f: Callable) Callable[source]

Creates a python function calling the onnx backend used by this class.

Parameters:

onx – onnx model

Returns:

python function

property dims

Returns the dimensions of the tensor. First dimension is the batch dimension if the tensor has more than one dimension. It is always left undefined.

property dtype: DType

Returns the element type of this tensor.

classmethod get_ir_version(ir_version)[source]

Updates the IR version. This method should be overloaded. By default, it returns ir_version.

classmethod get_opsets(opsets)[source]

Updates the opsets for a given backend. This method should be overloaded. By default, it returns opsets.

property key: Any

Unique key for a tensor of the same type.

property ndim

Returns the number of dimensions (rank).

numpy()[source]

Returns the array converted into a numpy array.

property shape: Tuple[int, ...]

Returns the shape of the tensor.

property tensor_type: TensorType

Returns the tensor type of this tensor.

tensor_type_dims(name: str) TensorType[source]

Returns the tensor type of this tensor. This property is used to define a key used to cache a jitted function. Same keys keys means same ONNX graph. Different keys usually means same ONNX graph but different input shapes.

Parameters:

name – name of the constraint

property value: ndarray

Returns the value of this tensor as a numpy array.