-
Notifications
You must be signed in to change notification settings - Fork 21.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[quant][pt2] Update special qspecs after QAT rewrite
Summary: Special qspecs like `SharedQuantizationSpec` and `DerivedQuantizationSpec` refer to other nodes in the graph. However, after subgraph rewriting in QAT, the nodes referred to in these special qspecs may be replaced by new nodes. This could lead to the following error when inserting observers according to these qspecs: ``` AssertionError: please make sure only refer to edge or node that has observer/fake_quant inserted: 'getitem' not in dict_keys([(arg0, convolution_default_1), (mul_tensor, convolution_default_1), getitem_3]) ``` This commit fixes this by keeping track of the nodes that are replaced during subgraph rewriting in QAT, and using this mapping to update the dangling references used in these special qspecs. Test Plan: python test/test_quantization.py TestQuantizePT2E.test_qat_update_shared_qspec Reviewed By: jerryzh168 Differential Revision: D46606614 fbshipit-source-id: 70e937c5aede94530073c729aaa6994b88141ed3
- Loading branch information
1 parent
678ce61
commit b647905
Showing
3 changed files
with
123 additions
and
25 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters