module onnxtorch.tchrun
#
Short summary#
module deeponnxcustom.onnxtorch.tchrun
Executes ONNX graph with pytorch.
Classes#
class |
truncated documentation |
---|---|
Executes ONNX graph using torch function. This is a very simple runtime. It goes through every node in the … |
Static Methods#
staticmethod |
truncated documentation |
---|---|
Builds a dictionary with all attributes |
|
Builds a dictionary with all initializers converted into torch arrays. |
|
Methods#
method |
truncated documentation |
---|---|
Executes a node with pytorch. Returns a dictionary. |
|
Executes the ONNX graph. |
Documentation#
Executes ONNX graph with pytorch.
- class deeponnxcustom.onnxtorch.tchrun.OnnxTorchRuntime(onnx_model)#
Bases:
object
Executes ONNX graph using torch function. This is a very simple runtime. It goes through every node in the ONNX graph and execute with the corresponding torch functions.
- Parameters
onnx_model – ONNX model
The class is very basic. It does not handle subgraphs and supports a limited number of operators.
<<<
import pprint from deeponnxcustom.onnxtorch.tchrun import OnnxTorchRuntime pprint.pprint(list(sorted(OnnxTorchRuntime._mapping)))
>>>
['Concat', 'Gather', 'Gemm', 'Identity', 'MatMul', 'Max', 'ReduceProd', 'ReduceSum', 'Reshape', 'Shape', 'Squeeze', 'Transpose', 'Unsqueeze']
- __init__(onnx_model)#
- static _extract_atts(onnx_model)#
Builds a dictionary with all attributes
- static _extract_init(onnx_model)#
Builds a dictionary with all initializers converted into torch arrays.
- _mapping = {'Concat': <function _function_OnnxTorchRuntime._concat>, 'Gather': <function _function_OnnxTorchRuntime._gather>, 'Gemm': <function _function_OnnxTorchRuntime._gemm>, 'Identity': <function OnnxTorchRuntime.<lambda>>, 'MatMul': <built-in method matmul of type object>, 'Max': <built-in method max of type object>, 'ReduceProd': <function _function_OnnxTorchRuntime._reduceprod>, 'ReduceSum': <function _function_OnnxTorchRuntime._reducesum>, 'Reshape': <function _function_OnnxTorchRuntime._reshape>, 'Shape': <function _function_OnnxTorchRuntime._shape>, 'Squeeze': <function _function_OnnxTorchRuntime._squeeze>, 'Transpose': <function _function_OnnxTorchRuntime._transpose>, 'Unsqueeze': <function _function_OnnxTorchRuntime._unqueeze>}#
- run(*inputs, verbose=False)#
Executes the ONNX graph.
- Parameters
inputs – inputs of the function
verbose – displays more information while running the graph
- Returns
a result or a tuple of results
- class deeponnxcustom.onnxtorch.tchrun._function_OnnxTorchRuntime#
Bases:
object
- static _concat(*tensors, axis=0)#
- static _gather(t, indices, axis=0)#
- static _gemm(a, b, c=None, alpha=1, beta=0, transA=False, transB=False)#
- static _reduceprod(data, axes=None, keepdims=1)#
- static _reducesum(data, axes=None, keepdims=1)#
- static _reshape(t, shape)#
- static _shape(t)#
- static _squeeze(data, axes=None)#
- static _transpose(t, perm)#
- static _unqueeze(t, dim)#