Skip to content

Conversation

maltanar
Copy link
Collaborator

@maltanar maltanar commented Oct 2, 2025

Introduce support for versioned CustomOps in QONNX while maintaining backwards compatibility.

Summary

The custom op registration should now look like this:

# unspecified version defaults to v1 implementation
# this is how we preserve backwards compatibility
general.custom_op["VerTestOp"] = VerTestOp_v1
# v1 and later versions are explicitly registered
general.custom_op["VerTestOp_v1"] = VerTestOp_v1
general.custom_op["VerTestOp_v2"] = VerTestOp_v2
general.custom_op["VerTestOp_v3"] = VerTestOp_v3

New code should use ModelWrapper.get_customop_wrapper to access wrappers, instead of the old getCustomOp. The new function ModelWrapper.get_customop_wrapper uses the opset imports in the ONNX file to fetch the correct version of the custom op wrapper, otherwise defaulting to a fallback version specifiable as a parameter.

The PR also sets the existing versions of QONNX custom ops to v1 and the fallback/default values for QONNX ops will return v1 as well, although there is no real versioning yet. The exception is for channels-last operators, which are supposed to mimic the original operator in its opset. For these, the PR uses a special custom_op registration handler that makes it possible to use arbitrary version numbers.

More detailed list of changes

  • Add get_opset_imports and get_customop_wrapper utility functions to ModelWrapper. The latter function should be used instead of the old getCustomOp as it uses the opset imports in the ONNX file to fetch the correct version of the custom op wrapper, otherwise defaulting to a fallback version specificable as a parameter.
  • Multiple changes to getCustomOp:
    • use default opset version None to indicate request for a wrapper for the default op version in the registry.
    • assuming a {CustomOp}_v{version} convention, retrieve the highest available version of the wrapper if opset version is specified.
  • Unit tests for the newly added functionality, including test_customop_verison.py
  • For channels-last operators, special custom_op registration handler that makes it possible to use arbitrary version numbers.

maltanar and others added 22 commits September 25, 2025 11:31
grabs CustomOp instance with the right opset version from protobuf
imported opsets
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant