Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[Quant][Fx] Fix issue: qconfig_mappings of onednn backend are not cor…
…rectly set for fused modules (#91297) **Summary** For onednn quantization backend only. Currently, FX fusion requires that all separate ops in a fused module/op have the same `qconfig`. To support `linear - leaky_relu` and `linear - tanh` fusion with onednn backend, we previously explicitly set the same `qconfig` to `linear`, `leaky_relu` and `tanh`. However, this brings two problems: - It breaks fusion of `linear - relu` since `relu` does not have the same `qconfig` as `linear` does. And it does not look good if we set `qconfig` to all these ops. They should use a global `qconfig` by default. - `Tanh` requires `fixed_qparams_qconfig` otherwise it is not quantized. So, we cannot set another `qconfig` to `tanh`. Looks like there is not a straightforward way to solve the problems. This PR fixes them by the following: - Do not set `qconfig` to these ops so that these ops use a global `qconfig` and `linear - relu` and `linear - leaky_relu` can be fused correctly. - Set the same `qconfig` to `linear` and `tanh` manually by users when they want to fuse `linear - tanh` with onednn backend. A known issue still exists: users cannot fuse `linear - tanh` and quantize standalone `tanh` at the same time. **Test plan** python test/test_quantization.py -k test_qconfig_dict_with_fused_modules Pull Request resolved: #91297 Approved by: https://github.com/jgong5, https://github.com/jerryzh168
- Loading branch information