pytorch/torch/quantization/fx/pattern_utils.py
Vasiliy Kuznetsov 7b4e92acef fx quant: refactor qconfig setting out of find_matches
Summary:

Refactors `find_matches` function to only find subgraph
matches and not assign qconfigs to them. Moves the qconfig assignment
outside of the function. No logic change.

This will useful for prototyping future tools for quantizing
parts of the model. These tools will need to know the matches
and will reuse the `find_matches` function,
but they will assign their own qconfigs to them using a different
strategy.

Test plan:

```
python test/test_quantization.py -k Fx
```

Pull Request resolved: https://github.com/pytorch/pytorch/pull/79713

Approved by: https://github.com/jerryzh168
2022-06-17 18:52:00 +00:00

33 lines
1.2 KiB
Python

# flake8: noqa: F401
r"""
This file is in the process of migration to `torch/ao/quantization`, and
is kept here for compatibility while the migration process is ongoing.
If you are adding a new entry/functionality, please, add it to the
appropriate files under `torch/ao/quantization/fx/`, while adding an import statement
here.
"""
from torch.ao.quantization.fx.pattern_utils import (
QuantizeHandler,
register_fusion_pattern,
get_default_fusion_patterns,
register_quant_pattern,
get_default_quant_patterns,
get_default_output_activation_post_process_map
)
# QuantizeHandler.__module__ = _NAMESPACE
register_fusion_pattern.__module__ = "torch.quantization.fx.pattern_utils"
get_default_fusion_patterns.__module__ = "torch.quantization.fx.pattern_utils"
register_quant_pattern.__module__ = "torch.quantization.fx.pattern_utils"
get_default_quant_patterns.__module__ = "torch.quantization.fx.pattern_utils"
get_default_output_activation_post_process_map.__module__ = "torch.quantization.fx.pattern_utils"
# __all__ = [
# "QuantizeHandler",
# "register_fusion_pattern",
# "get_default_fusion_patterns",
# "register_quant_pattern",
# "get_default_quant_patterns",
# "get_default_output_activation_post_process_map",
# ]