Skip to content

Commit

Permalink
quantization: make x86 as default backend (#88799)
Browse files Browse the repository at this point in the history
Pull Request resolved: #88799
Approved by: https://github.com/kit1980
  • Loading branch information
XiaobingSuper authored and pytorchmergebot committed Dec 1, 2022
1 parent 0e7918b commit 4bae860
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 11 deletions.
2 changes: 1 addition & 1 deletion aten/src/ATen/Context.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -332,8 +332,8 @@ const std::vector<at::QEngine>& Context::supportedQEngines() {

#ifdef USE_FBGEMM
if (fbgemm::fbgemmSupportedCPU()) {
// The X86 qengine is available if and only if FBGEMM is available
engines.push_back(at::kX86);
// The X86 qengine is available if and only if FBGEMM is available
engines.push_back(at::kFBGEMM);
}
#endif
Expand Down
12 changes: 6 additions & 6 deletions torch/ao/quantization/qconfig.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,13 +218,13 @@ def __new__(cls, activation=torch.nn.Identity, weight=torch.nn.Identity):
Default qconfig for operators that reuse the observers from input Tensor, e.g. reshape
"""

def get_default_qconfig(backend='fbgemm', version=0):
def get_default_qconfig(backend='x86', version=0):
"""
Returns the default PTQ qconfig for the specified backend.
Args:
* `backend` (str): a string representing the target backend. Currently supports
`x86`, `fbgemm` (default), `qnnpack` and `onednn`.
`x86` (default), `fbgemm`, `qnnpack` and `onednn`.
Return:
qconfig
Expand Down Expand Up @@ -301,13 +301,13 @@ def get_default_qconfig(backend='fbgemm', version=0):
default_embedding_qat_qconfig_4bit = QConfig(activation=NoopObserver.with_args(dtype=torch.float32),
weight=default_embedding_fake_quant_4bit)

def get_default_qat_qconfig(backend='fbgemm', version=1):
def get_default_qat_qconfig(backend='x86', version=1):
"""
Returns the default QAT qconfig for the specified backend.
Args:
* `backend` (str): a string representing the target backend. Currently supports
`x86`, `fbgemm` (default), `qnnpack` and `onednn`.
`x86` (default), `fbgemm`, `qnnpack` and `onednn`.
* `version`: version, for backwards compatibility. Can be `None` or `1`.
Return:
Expand Down Expand Up @@ -402,13 +402,13 @@ def get_default_qat_qconfig(backend='fbgemm', version=1):
eps=2 ** -12),
weight=fused_per_channel_wt_fake_quant_range_neg_127_to_127)

def get_default_qconfig_dict(backend='fbgemm', version=0):
def get_default_qconfig_dict(backend='x86', version=0):
warnings.warn(
"torch.ao.quantization.get_default_qconfig_dict is deprecated and will be removed in "
"a future version. Please use torch.ao.quantization.get_default_qconfig_mapping instead.")
return torch.ao.quantization.get_default_qconfig_mapping(backend, version).to_dict()

def get_default_qat_qconfig_dict(backend='fbgemm', version=1):
def get_default_qat_qconfig_dict(backend='x86', version=1):
warnings.warn(
"torch.ao.quantization.get_default_qat_qconfig_dict is deprecated and will be removed in "
"a future version. Please use torch.ao.quantization.get_default_qat_qconfig_mapping instead.")
Expand Down
8 changes: 4 additions & 4 deletions torch/ao/quantization/qconfig_mapping.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,25 +122,25 @@ def _get_default_qconfig_mapping(is_qat: bool, backend: str, version: int) -> QC

return qconfig_mapping

def get_default_qconfig_mapping(backend="fbgemm", version=0) -> QConfigMapping:
def get_default_qconfig_mapping(backend="x86", version=0) -> QConfigMapping:
"""
Return the default QConfigMapping for post training quantization.
Args:
* ``backend`` (str) : the quantization backend for the default qconfig mapping, should be
one of ["x86", "fbgemm" (default), "qnnpack", "onednn"]
one of ["x86" (default), "fbgemm", "qnnpack", "onednn"]
* ``version`` (int) : the version for the default qconfig mapping
"""
# TODO: add assert for backend choices
return _get_default_qconfig_mapping(False, backend, version)

def get_default_qat_qconfig_mapping(backend="fbgemm", version=1) -> QConfigMapping:
def get_default_qat_qconfig_mapping(backend="x86", version=1) -> QConfigMapping:
"""
Return the default QConfigMapping for quantization aware training.
Args:
* ``backend`` (str) : the quantization backend for the default qconfig mapping, should be
one of ["x86", "fbgemm" (default), "qnnpack", "onednn"]
one of ["x86" (default), "fbgemm", "qnnpack", "onednn"]
* ``version`` (int) : the version for the default qconfig mapping
"""
return _get_default_qconfig_mapping(True, backend, version)
Expand Down

0 comments on commit 4bae860

Please sign in to comment.