)
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,
# 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}.")
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
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