Skip to content

Commit

Permalink
fix key mapping loop
Browse files Browse the repository at this point in the history
  • Loading branch information
Ofir Gordon authored and Ofir Gordon committed Jan 31, 2024
1 parent 3dc9e09 commit 0ff82cd
Showing 1 changed file with 13 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def clone_and_edit_weight_attribute(self, attrs: List[str] = None, **kwargs):

def clone_and_map_weights_attr_keys(self, layer_attrs_mapping: Union[Dict[str, str], None]):
"""
Clones the quantization configuration options and edits the keys in the each configuration attributes config mapping,
Clones the quantization configuration options and edits the keys in each configuration attributes config mapping,
based on the given attributes names mapping.
Args:
Expand All @@ -304,12 +304,18 @@ def clone_and_map_weights_attr_keys(self, layer_attrs_mapping: Union[Dict[str, s
qc_options = copy.deepcopy(self)

for qc in qc_options.quantization_config_list:
for attr in list(qc.attr_weights_configs_mapping.keys()):
if layer_attrs_mapping is None:
qc.attr_weights_configs_mapping = {}
else:
qc.attr_weights_configs_mapping[layer_attrs_mapping[attr]] = (
qc.attr_weights_configs_mapping.pop(attr))
if layer_attrs_mapping is None:
qc.attr_weights_configs_mapping = {}
else:
new_attr_mapping = {}
for attr in list(qc.attr_weights_configs_mapping.keys()):
new_key = layer_attrs_mapping.get(attr)
if new_key is None:
Logger.error(f"Attribute {attr} does not exist in the given attribute mapping.")

new_attr_mapping[new_key] = qc.attr_weights_configs_mapping.pop(attr)

qc.attr_weights_configs_mapping.update(new_attr_mapping)

return qc_options

Expand Down

0 comments on commit 0ff82cd

Please sign in to comment.