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

Updated QONNX parsing #832

Closed
wants to merge 15 commits into from
Closed

Conversation

jmitrevs
Copy link
Contributor

Description

This change updates the ONNX parser and adds support for QONNX. It replaces PR #591. It only supports ONNX that has been cleaned by the qonnx package, including converting convolutions to be channels-last and changing Gemm to MatMul and Add.

In QONNX Quant nodes can act on constants as well as the datapath. To make handling this easier, we explicitly put constants in the initial graph. There are also some helper nodes like MatMul and Conv that are introduced to support the explicit constant nodes. After the convert flow, no special ONNX nodes remain in the graph, though.

Generally Quant nodes that have power-of-2 scales and no zero-offset get converted to fixed data types either by setting the types of constants or adding a linear activation that is usually merged into preceding nodes. Non-power-of-2 scales result in ApplyAlpha nodes beings added to scale and unscale, with propagation across some layers. This can be further optimized and has generally been tested less.

Binary networks are not yet supported.

Currently some of the automatic type setting depends on QONNX-set attributes. When we introduce auto type values, this should be updated accordingly.

Type of change

  • New feature (non-breaking change which adds functionality)
  • A new research paper code implementation

Tests

The pytest, test_qonnx.py, is the main test, building some models from the QONNX model zoo

Checklist

  • I have read the guidelines for contributing.
  • I have commented my code, particularly in hard-to-understand areas.
  • I have made corresponding changes to the documentation.
  • My changes generate no new warnings.
  • I have installed and run pre-commit on the files I edited or added.
  • I have added tests that prove my fix is effective or that my feature works.

@jmitrevs jmitrevs added this to the v0.8.0 milestone Jul 13, 2023
@jmitrevs jmitrevs added the please test Trigger testing by creating local PR branch label Jul 13, 2023
@jmitrevs
Copy link
Contributor Author

My understanding of when the dimensions include a batch dimension and when it didn't seems to not be right. Will investigate. For ONNX can't depend on the batch dimension being None.

@jmitrevs jmitrevs added enhancement please test Trigger testing by creating local PR branch and removed please test Trigger testing by creating local PR branch labels Jul 18, 2023
@jmitrevs jmitrevs added please test Trigger testing by creating local PR branch and removed please test Trigger testing by creating local PR branch labels Aug 2, 2023
@jmitrevs jmitrevs marked this pull request as draft August 4, 2023 23:42
@jmitrevs jmitrevs modified the milestones: v0.8.0, v1.0.0 Oct 20, 2023
@jmitrevs jmitrevs mentioned this pull request Mar 12, 2024
8 tasks
@jmitrevs
Copy link
Contributor Author

This is being replaced with PR #979.

@jmitrevs jmitrevs closed this Mar 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement please test Trigger testing by creating local PR branch
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant