Skip to content

Commit 8dbbe05

Browse files
committed
[Core] inrtoduce ModelWrapper.get_customop_wrapper
grabs CustomOp instance with the right opset version from protobuf imported opsets
1 parent 1560343 commit 8dbbe05

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/qonnx/core/modelwrapper.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
import qonnx.util.basic as util
4040
import qonnx.util.onnx as onnxutil
4141
from qonnx.core.datatype import DataType
42-
from qonnx.custom_op.registry import is_custom_op
42+
from qonnx.custom_op.registry import getCustomOp, is_custom_op
4343
from qonnx.transformation.double_to_single_float import DoubleToSingleFloat
4444
from qonnx.transformation.general import (
4545
RemoveStaticGraphInputs,
@@ -742,3 +742,10 @@ def set_tensor_sparsity(self, tensor_name, sparsity_dict):
742742
def get_opset_imports(self):
743743
"""Returns a list of imported opsets as a {domain, version} dictionary."""
744744
return {opset.domain: opset.version for opset in self._model_proto.opset_import}
745+
746+
def get_customop_wrapper(self, node):
747+
"""Return CustomOp instance for given node, respecting the
748+
imported opset version in the model protobuf."""
749+
opset_imports = self.get_opset_imports()
750+
opset_import = opset_imports[node.domain]
751+
return getCustomOp(node, onnx_opset_version=opset_import)

0 commit comments

Comments
 (0)