mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-21 05:34:18 +08:00
Summary: Following https://github.com/pytorch/rfcs/blob/master/RFC-0019-Extending-PyTorch-Quantization-to-Custom-Backends.md we implemented the backend configuration for fbgemm/qnnpack backend, currently it was under fx folder, but we'd like to use this for all different workflows, including eager, fx graph and define by run quantization, this PR moves it to torch.ao.quantization namespace so that it can be shared by different workflows Also moves some utility functions specific to fx to fx/backend_config_utils.py and some files are kept in fx folder (quantize_handler.py and fuse_handler.py) Test Plan: python test/teset_quantization.py TestQuantizeFx python test/teset_quantization.py TestQuantizeFxOps python test/teset_quantization.py TestQuantizeFxModels python test/test_quantization.py TestAOMigrationQuantization python test/test_quantization.py TestAOMigrationQuantizationFx Reviewers: Subscribers: Tasks: Tags: Pull Request resolved: https://github.com/pytorch/pytorch/pull/75823 Approved by: https://github.com/vkuzo
24 lines
744 B
Python
24 lines
744 B
Python
"""
|
|
This script will generate default values of quantization configs.
|
|
These are for use in the documentation.
|
|
"""
|
|
|
|
from torch.ao.quantization.backend_config import get_native_backend_config_dict
|
|
import os.path
|
|
from pprint import pprint
|
|
|
|
|
|
# Create a directory for the images, if it doesn't exist
|
|
QUANTIZATION_BACKEND_CONFIG_IMAGE_PATH = os.path.join(
|
|
os.path.realpath(os.path.join(__file__, "..")),
|
|
"quantization_backend_configs"
|
|
)
|
|
|
|
if not os.path.exists(QUANTIZATION_BACKEND_CONFIG_IMAGE_PATH):
|
|
os.mkdir(QUANTIZATION_BACKEND_CONFIG_IMAGE_PATH)
|
|
|
|
output_path = os.path.join(QUANTIZATION_BACKEND_CONFIG_IMAGE_PATH, "default_backend_config.txt")
|
|
|
|
with open(output_path, "w") as f:
|
|
pprint(get_native_backend_config_dict(), stream=f)
|