Real quantization cast for PTQ
Related to Issue:#59 (closed)
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 (closed)
removed StatusWork in Progress label
added StatusReview Ready label