onnx.backend

Backend

class onnx.backend.base.Backend[source]
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, ...]][source]

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[source]

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[source]

collect_snippets

Device

class onnx.backend.base.Device(
device: str
)[source]

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

DeviceType

class onnx.backend.base.DeviceType[source]

load_model_tests

Runner

class onnx.backend.test.runner.Runner(
backend: Type[Backend],
parent_module: Optional[str] = None
)[source]
property test_cases: Dict[str, Type[TestCase]]

List of test cases to be applied on the parent scope Example usage:

globals().update(BackendTest(backend).test_cases)

property test_suite: TestSuite

TestSuite that can be run by TestRunner Example usage:

unittest.TextTestRunner().run(BackendTest(backend).test_suite)

property tests: Type[TestCase]

One single unittest.TestCase that hosts all the test functions Example usage:

onnx_backend_tests = BackendTest(backend).tests

TestCase

class onnx.backend.test.case.test_case.TestCase(
name: str,
model_name: str,
url: Optional[str],
model_dir: Optional[str],
model: Optional[onnx.onnx_ml_pb2.ModelProto],
data_sets: Optional[Sequence[Tuple[Sequence[numpy.ndarray], Sequence[numpy.ndarray]]]],
kind: str,
rtol: float,
atol: float,
__test__: bool = False
)[source]