dbr quant overhead[11/x]: speed up module convert hook (#68837)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/68837
The module convert hook dequantizes the module outputs if the user
requested the module to adhere to a certain dtype for outputs. This
is most commonly used for the assumption that a model's overall return
type if fp32.
This PR precalculates for each module whether this hook will do anything,
and returns early if it does not. This prevents the overhead of this
hook to influencing any module which does not need this hook.
Test Plan:
```
python test/test_quantization.py TestQuantizeDBR
```
perf
```
MobileNetV2, 1x3x224x224, function level profiling
// before
outputs_convert_hook - 0.73%
// before
outputs_convert_hook - 0.45%
```
Reviewed By: jerryzh168
Differential Revision: D32630885
Pulled By: vkuzo
fbshipit-source-id: 7ee84de742fc0c752b66d20d097405a754c8b480