onnx.backend¶
Backend¶
- class onnx.backend.base.Backend[source]¶
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: Sequence[tuple[dtype, tuple[int, ...]]] | None = None, **kwargs: dict[str, Any]) tuple[Any, ...] | None [source]¶
Simple run one operator and return the results.
- Parameters:
node – The node proto.
inputs – Inputs to the node.
device – The device to run on.
outputs_info – a list of tuples, which contains the element type and shape of each output. First element of the tuple is the dtype, and the second element is the shape. More use case can be found in https://github.com/onnx/onnx/blob/main/onnx/backend/test/runner/__init__.py
kwargs – Other keyword arguments.