onnx.backend#

Backend#

class onnx.backend.base.Backend#

Backend is the entity that will take an ONNX model with inputs, perform a computation, and then return the output.

For one-off execution, users can use run_node and run_model to obtain results quickly.

For repeated execution, users should use prepare, in which the Backend does all of the preparation work for executing the model repeatedly (e.g., loading initializers), and returns a BackendRep handle.

classmethod run_node(node: NodeProto, inputs: Any, device: str = 'CPU', outputs_info: Optional[Sequence[Tuple[dtype, Tuple[int, ...]]]] = None, **kwargs: Dict[str, Any]) Optional[Tuple[Any, ...]]#

Simple run one operator and return the results. :param outputs_info: a list of tuples, which contains the element type and :param shape of each output. First element of the tuple is the dtype: :param and: :param the second element is the shape. More use case can be found in: :param https: //github.com/onnx/onnx/blob/main/onnx/backend/test/runner/__init__.py

classmethod supports_device(device: str) bool#

Checks whether the backend is compiled with particular device support. In particular it’s used in the testing suite.

BackendRep#

class onnx.backend.base.BackendRep#

BackendRep is the handle that a Backend returns after preparing to execute a model repeatedly. Users will then pass inputs to the run function of BackendRep to retrieve the corresponding results.

run(inputs: Any, **kwargs: Any) Tuple[Any, ...]#

Abstract function.

Device#

class onnx.backend.base.Device(device: str)#

Describes device type and device id syntax: device_type:device_id(optional) example: ‘CPU’, ‘CUDA’, ‘CUDA:1’

__init__(device: str) None#

DeviceType#

class onnx.backend.base.DeviceType#

Describes device type.

_Type#

alias of int

__annotations__ = {'CPU': <function NewType.<locals>.new_type>, 'CUDA': <function NewType.<locals>.new_type>}#

load_model_tests#

onnx.backend.test.loader.load_model_tests(data_dir: str = 'somewhere/workspace/onnxcustom/onnxcustom_UT_39_std/_venv/lib/python3.9/site-packages/onnx/backend/test/data', kind: Optional[str] = None) List[TestCase]#

Load model test cases from on-disk data files.