Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Op Registry upgrade #144

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 18 additions & 1 deletion src/qonnx/custom_op/registry.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,24 @@

import importlib

from qonnx.util.basic import get_preferred_onnx_opset
_QONNX_DOMAINS = ["finn", "qonnx.custom_op", "onnx.brevitas"]


def register_custom_domain(domain: str):
_QONNX_DOMAINS.append(domain)


def is_finn_op(op_type):
"Return whether given op_type string is a QONNX or FINN custom op"
is_finn = False
for domain in _QONNX_DOMAINS:
is_finn = is_finn or op_type.startswith(domain)
return is_finn


def get_preferred_onnx_opset():
"Return preferred ONNX opset version for QONNX"
return 11


def getCustomOp(node, onnx_opset_version=get_preferred_onnx_opset(), brevitas_exception=True):
Expand Down
8 changes: 5 additions & 3 deletions src/qonnx/util/basic.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@
import string
import warnings

import qonnx
import qonnx.custom_op
import qonnx.custom_op.registry
from qonnx.core.datatype import DataType

# TODO solve by moving onnx-dependent fxns to onnx.py
Expand All @@ -48,7 +51,7 @@

def get_preferred_onnx_opset():
"Return preferred ONNX opset version for QONNX"
return 11
return qonnx.custom_op.registry.get_preferred_onnx_opset()


def qonnx_make_model(graph_proto, **kwargs):
Expand All @@ -63,8 +66,7 @@ def qonnx_make_model(graph_proto, **kwargs):


def is_finn_op(op_type):
"Return whether given op_type string is a QONNX or FINN custom op"
return op_type.startswith("finn") or op_type.startswith("qonnx.custom_op") or op_type.startswith("onnx.brevitas")
return qonnx.custom_op.registry.is_finn_op(op_type)


def get_num_default_workers():
Expand Down
Loading