Updating the names of these functions (#63513)
authorCharles David Hernandez <cdhernandez@fb.com>
Thu, 19 Aug 2021 20:04:48 +0000 (13:04 -0700)
committerFacebook GitHub Bot <facebook-github-bot@users.noreply.github.com>
Thu, 19 Aug 2021 20:34:34 +0000 (13:34 -0700)
Summary:
Pull Request resolved: https://github.com/pytorch/pytorch/pull/63513

updating these names per Jerry's nits in the previous pr

Test Plan: Imported from OSS

Reviewed By: jerryzh168

Differential Revision: D30406710

fbshipit-source-id: a9f1577a2b8c4a93f5005e0f6278b7d7348d8b66

torch/quantization/fx/prepare.py
torch/quantization/qconfig.py

index 23d1d40..29600b8 100644 (file)
@@ -15,7 +15,7 @@ from torch.fx.graph import (
 )
 from torch.fx.node import Argument
 
-from ..qconfig import QConfigAny, qconfig_function_equality
+from ..qconfig import QConfigAny, qconfig_equals
 from .qconfig_utils import (
     convert_dict_to_ordered_dict,
     generate_qconfig_map,
@@ -195,7 +195,7 @@ def update_qconfig_for_fusion(
                     # Raise an error if the modules in the fused module have
                     # different qconfigs specified in the qconfig_dict
                     for op in ops:
-                        if not qconfig_function_equality(object_type_dict.get(op, None), fused_qconfig):
+                        if not qconfig_equals(object_type_dict.get(op, None), fused_qconfig):
                             raise LookupError("During fusion, we need to specify the same " +
                                               f"qconfigs for both modules in {module_type}.")
 
index 01d67dd..ae89b4a 100644 (file)
@@ -211,9 +211,9 @@ def add_module_to_qconfig_obs_ctr(
         return QConfigDynamic(activation, weight)
 
 
-def qconfig_function_equality(q1: QConfigAny, q2: QConfigAny):
+def qconfig_equals(q1: QConfigAny, q2: QConfigAny):
     # functools.partial has no __eq__ operator defined so '==' defaults to 'is'
-    def compare_partial(p1, p2):
+    def partial_equals(p1, p2):
         same = p1.func == p2.func
         same = same and p1.args == p2.args
         return same and p1.keywords == p2.keywords
@@ -223,6 +223,6 @@ def qconfig_function_equality(q1: QConfigAny, q2: QConfigAny):
     else:
         assert q1 is not None and q2 is not None
         try:
-            return compare_partial(q1.activation.p, q2.activation.p) and compare_partial(q1.weight.p, q2.weight.p)
+            return partial_equals(q1.activation.p, q2.activation.p) and partial_equals(q1.weight.p, q2.weight.p)
         except AttributeError:
             return q1 == q2