ONNXRuntimeAdapter#

class ONNXRuntimeAdapter[source]#

Bases: object

Wrapper around ONNX-runtime that behaves like a PyTorch nn.Module.

That is, it implements __call__() and accepts PyTorch Tensors as inputs and also outputs PyTorch Tensors.

__init__(ort_session: ort.InferenceSession) None[source]#

Constructor.

Parameters

ort_session (ort.InferenceSession) – ONNX-runtime InferenceSession.

Return type

None

Methods

__init__(ort_session)

Constructor.

from_file(path[, providers])

Construct from file.

__init__(ort_session: ort.InferenceSession) None[source]#

Constructor.

Parameters

ort_session (ort.InferenceSession) – ONNX-runtime InferenceSession.

Return type

None

classmethod from_file(path: str, providers: Optional[List[str]] = None) ONNXRuntimeAdapter[source]#

Construct from file.

Parameters
  • path (str) – Path to a .onnx file.

  • providers (Optional[List[str]]) – ONNX-runtime execution providers. See onnxruntime documentation for more details. Defaults to None.

Returns

An ONNXRuntimeAdapter instance.

Return type

ONNXRuntimeAdapter