Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions neural_compressor/common/base_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -377,6 +377,9 @@ def expand(self) -> List[BaseConfig]:
if len(tuning_param_list) == 0:
config_list = [config]
else:
# The `TuningParam` instance with no options will cause the product to be empty.
# Filter out the `TuningParam` instances with no options
tuning_param_list = list(filter(lambda x: len(x.options) > 0, tuning_param_list))
tuning_param_name_lst = [tuning_param.name for tuning_param in tuning_param_list]
for params_values in product(*[tuning_param.options for tuning_param in tuning_param_list]):
tuning_param_pair = dict(zip(tuning_param_name_lst, params_values))
Expand Down
5 changes: 5 additions & 0 deletions test/3x/common/test_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -277,6 +277,11 @@ def test_config_expand_complex_tunable_type(self):
for i in range(len(configs_list)):
self.assertEqual(configs_list[i].target_op_type_list, target_op_type_list_options[i])

def test_config_expand_with_empty_options(self):
configs = FakeAlgoConfig(weight_dtype=["int", "float32"], weight_bits=[])
configs_list = configs.expand()
self.assertEqual(len(configs_list), 2)

def test_mixed_two_algos(self):
model = FakeModel()
OP1_NAME = "OP1_NAME"
Expand Down