Skip to content

Commit c7beb15

Browse files
committed
at: enable sweeping over categorical/string parameters in sweep mode
* can now perform multi-parameter sweeps combining numeric ranges and discrete string choices Signed-off-by: Jack Luar <jluar@precisioninno.com>
1 parent 961ba3f commit c7beb15

2 files changed

Lines changed: 18 additions & 5 deletions

File tree

tools/AutoTuner/src/autotuner/distributed.py

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -569,13 +569,24 @@ def sweep():
569569
queue = Queue()
570570
parameter_list = list()
571571
for name, content in config_dict.items():
572-
if not isinstance(content, list):
572+
if isinstance(content, dict) and content.get("type") == "string":
573+
if "values" not in content:
574+
print(
575+
f"[ERROR TUN-0016] {name} string parameter missing 'values' field."
576+
)
577+
sys.exit(1)
578+
if not isinstance(content["values"], list) or len(content["values"]) == 0:
579+
print(f"[ERROR TUN-0017] {name} 'values' must be a non-empty list.")
580+
sys.exit(1)
581+
parameter_list.append([{name: i} for i in content["values"]])
582+
elif isinstance(content, list):
583+
if content[-1] == 0:
584+
print("[ERROR TUN-0014] Sweep does not support step value zero.")
585+
sys.exit(1)
586+
parameter_list.append([{name: i} for i in np.arange(*content)])
587+
else:
573588
print(f"[ERROR TUN-0015] {name} sweep is not supported.")
574589
sys.exit(1)
575-
if content[-1] == 0:
576-
print("[ERROR TUN-0014] Sweep does not support step value zero.")
577-
sys.exit(1)
578-
parameter_list.append([{name: i} for i in np.arange(*content)])
579590
parameter_list = list(product(*parameter_list))
580591
for parameter in parameter_list:
581592
temp = dict()

tools/AutoTuner/src/autotuner/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,8 @@ def read(path):
442442
return ret
443443

444444
def read_sweep(this):
445+
if this.get("type") == "string":
446+
return {"type": "string", "values": this["values"]}
445447
return [*this["minmax"], this["step"]]
446448

447449
def apply_condition(config, data):

0 commit comments

Comments
 (0)