qonnx icon indicating copy to clipboard operation
qonnx copied to clipboard

Op Registry upgrade

Open jurevreca12 opened this issue 1 year ago • 1 comments

This PR makes it possible to add QONNX Ops from outside the brevitas/finn/qonnx repositories. It adds a function register_custom_domain .

This is an example of usage of this functionality in chisel4ml: - https://github.com/cs-jsi/chisel4ml/blob/auto_parameters/chisel4ml/preprocess/fft_torch_op.py - https://github.com/cs-jsi/chisel4ml/blob/auto_parameters/chisel4ml/preprocess/fft_qonnx_op.py

It defines a custom pytorch op, that then gets mapped to a (Q)ONNX op.

This PR should not affect other peoples code.

jurevreca12 avatar Sep 13 '24 14:09 jurevreca12

I just realized I forgot to add the example code where register_custom_domain function is used. The examples above define the ops. However, first the register_custom_domain is called https://github.com/cs-jsi/chisel4ml/blob/auto_parameters/chisel4ml/transform.py#L87, and the ops are imported into the "chisel4ml" namespace inside chise4ml/__init__.py (because QONNX equates the domain name with the python namespace).

jurevreca12 avatar Sep 19 '24 07:09 jurevreca12

Can maybe more documentation be added?

jmitrevs avatar Sep 04 '25 15:09 jmitrevs

There are now two PRs on this topic. The other being #204 . It also proposes more changes. However, from a quick glance, it seems that it removes the "brevitas exception". Which might break FINN code?

jurevreca12 avatar Sep 29 '25 07:09 jurevreca12

However, from a quick glance, it seems that it removes the "brevitas exception". Which might break FINN code?

The PR adds a "domain aliasing" system (Lines 36-39 in registry.py) to more generically address the issue of CustomOp domain redirection, with the "brevitas exception" aliased by default. This has worked with FINN in my testing, but please let me know if you encounter any issues.

tafk7 avatar Sep 29 '25 07:09 tafk7

@jurevreca12 the PR #204 has been tested against FINN previously, and it seems a bit more documented. Can you please review it and see if it solves what you were trying to address in this PR (#144) ? If it does, I suggest we go for #204 instead.

maltanar avatar Sep 30 '25 14:09 maltanar

@maltanar agree. I will close this PR, and review #204 .

jurevreca12 avatar Sep 30 '25 17:09 jurevreca12