Skip to content

Commit 6b27383

Browse files
authored
Fix config expansion with empty options (#1861)
Signed-off-by: yiliu30 <yi4.liu@intel.com>
1 parent 25c71aa commit 6b27383

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

neural_compressor/common/base_config.py

+3
Original file line numberDiff line numberDiff line change
@@ -377,6 +377,9 @@ def expand(self) -> List[BaseConfig]:
377377
if len(tuning_param_list) == 0:
378378
config_list = [config]
379379
else:
380+
# The `TuningParam` instance with no options will cause the product to be empty.
381+
# Filter out the `TuningParam` instances with no options
382+
tuning_param_list = list(filter(lambda x: len(x.options) > 0, tuning_param_list))
380383
tuning_param_name_lst = [tuning_param.name for tuning_param in tuning_param_list]
381384
for params_values in product(*[tuning_param.options for tuning_param in tuning_param_list]):
382385
tuning_param_pair = dict(zip(tuning_param_name_lst, params_values))

test/3x/common/test_common.py

+5
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,11 @@ def test_config_expand_complex_tunable_type(self):
277277
for i in range(len(configs_list)):
278278
self.assertEqual(configs_list[i].target_op_type_list, target_op_type_list_options[i])
279279

280+
def test_config_expand_with_empty_options(self):
281+
configs = FakeAlgoConfig(weight_dtype=["int", "float32"], weight_bits=[])
282+
configs_list = configs.expand()
283+
self.assertEqual(len(configs_list), 2)
284+
280285
def test_mixed_two_algos(self):
281286
model = FakeModel()
282287
OP1_NAME = "OP1_NAME"

0 commit comments

Comments
 (0)