Skip to content

Commit e7737d6

Browse files
fixed to check for integer or string
1 parent c49ba74 commit e7737d6

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

model_compression_toolkit/core/common/quantization/bit_width_config.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,12 +211,19 @@ def _construct_node_to_new_weights_bit_mapping(self, graph) -> Dict:
211211

212212
for n in filtered_nodes:
213213
attr_to_change_bit_width = []
214-
214+
215215
attrs_str = n.get_node_weights_attributes()
216216
if len(attrs_str) == 0:
217217
Logger.critical(f'The requested attribute {manual_bit_width_selection.attr} to change the bit width for {n} does not exist.')
218218

219-
attr = [attr_str for attr_str in attrs_str if attr_str.find(manual_bit_width_selection.attr) != -1]
219+
attr = []
220+
for attr_str in attrs_str:
221+
if isinstance(attr_str, str) and isinstance(manual_bit_width_selection.attr, str):
222+
if attr_str.find(manual_bit_width_selection.attr) != -1:
223+
attr.append(attr_str)
224+
elif isinstance(attr_str, int) and isinstance(manual_bit_width_selection.attr, int):
225+
if attr_str == manual_bit_width_selection.attr:
226+
attr.append(attr_str)
220227
if len(attr) == 0:
221228
Logger.critical(f'The requested attribute {manual_bit_width_selection.attr} to change the bit width for {n} does not exist.')
222229

0 commit comments

Comments
 (0)