Real quantization cast for PTQ
Related to Issue:#59
This MR aims to bring real quantization and Graph Integer Execution in AIDGE quantization module (Solving this issue [aidge_backend_cpu#35]):
Changes for now:
- PTQ.cpp: Creation of a CastNetwork Routine that directly cast the network into the target type. The routine differentiates between normal mode and single-shift mode, inserting either BitShift or IntQuantizer accordingly. IntQuantizer is a modified version of the quantizer operator that allows execution within a fully integer network, as this new meta-operator enables casting the input to Float and the output to Int.
Also, I added the foldGraph flag in the quantizeNetwork() function. When this flag is set to true, the pipeline will now apply the constant folding recipe to the graph, making it much simpler and more readable by 'removing' all the intermediate PTQ nodes inserted, from the user's perspective.
- PTQMetaOps.(h/c)pp Adding the new metaoperator IntQuantizer and BitShiftQuantizer
Results: We obtain exactly the same results for MiniResNet as when using the fake quantization pipeline (with and without SingleShift). For ResNet18, we observe a slight drop in accuracy from 68.7% to 67.6% in Int32 with SingleShift, due to the approximation of the Global Average Pooling operator in integer arithmetic.
Also there is now a functional testsuite to prevent regression in the PTQ pipeline (aidge_quantization/aidge_quantization/unit_tests/test_ptq.py) [#64 (closed)\]
Quick fix to solve this issue: #19 (comment 3112773)
What remains to be done:
- Add support for Int8
Merge request reports
Activity
added Feature 🚀 StatusWork in Progress labels
requested review from @bhalimi
assigned to @noamzerah
added 1 commit
- 6c9a568d - Adding clearInput method to supress Int32 inputs after PTQ
added 1 commit
- 774c5f9d - Fixing deprecated ways of getting all the nodes in graphview
@noamzerah everything looks good to me, excepted the code of
PTQMetaOps
that i feel could be factorized ! :)Edited by Benjamin Halimiadded 1 commit
- fc524226 - Fixing clearGraphViewInputNode chich automatically cast all input of the GV...
mentioned in issue aidge_core#239 (closed)
mentioned in issue aidge_backend_cpu#35
added 1 commit
- 30f8212d - INtegrating the new ptq testsuite into the CI
mentioned in issue #59
removed StatusWork in Progress label
added StatusReview Ready label
added 15 commits
-
30f8212d...f2713d00 - 7 commits from branch
eclipse/aidge:dev
- f38da961 - first change
- 1d1fa3a4 - Adding changes
- 67a29eb2 - Rebasing real quantization cast onto dev
- 7cf77a7e - Adding bitshift rounding option
- f66860a3 - Adding clearInput method to supress Int32 inputs after PTQ
- 44a47ae8 - Correcting issue with targettype
- bf1783f3 - Fixing clearGraphViewInputNode chich automatically cast all input of the GV...
- e79d0618 - INtegrating the new ptq testsuite into the CI
Toggle commit list-
30f8212d...f2713d00 - 7 commits from branch
@noamzerah What is the status of this MR? Is this really review ready it looks like it is still under dev, should we set it to Draft and Work In Progress?
This MR is almost finished. I talked with @bhalimi today, and only a few minor modifications are missing.
removed StatusReview Ready label
added StatusWork in Progress label
reset approvals from @bhalimi by pushing to the branch
removed StatusWork in Progress label
added StatusReview Ready label
added 35 commits
-
ce4864db...3f669a98 - 23 commits from branch
eclipse/aidge:dev
- 3f669a98...5728ab0d - 2 earlier commits
- d1e683b9 - Rebasing real quantization cast onto dev
- bd5f3d62 - Adding bitshift rounding option
- ec544068 - Adding clearInput method to supress Int32 inputs after PTQ
- 76e033fb - Correcting issue with targettype
- 1104463b - Fixing clearGraphViewInputNode chich automatically cast all input of the GV...
- 874ae4ad - INtegrating the new ptq testsuite into the CI
- 6f99f885 - new
- 30244425 - Adding ONNX assets
- 1e320d3b - Fixing resetInput() with MetaOps
- 2fe4cba6 - Last Fix
Toggle commit list-
ce4864db...3f669a98 - 23 commits from branch
reset approvals from @bhalimi by pushing to the branch
mentioned in commit 1553e9ef