Skip to content

Commit c2c9458

Browse files
committed
Improvements to the stop criterion and cost function return values
1 parent 20ea709 commit c2c9458

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

kernel_tuner/strategies/common.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -180,7 +180,8 @@ def __call__(self, x, check_restrictions=True):
180180
return_value = result[self.tuning_options.objective]
181181
else:
182182
return_value = result[self.tuning_options.objective] or sys.float_info.max
183-
return_value = -return_value if self.tuning_options.objective_higher_is_better else return_value
183+
if not isinstance(return_value, util.ErrorConfig):
184+
return_value = -return_value if self.tuning_options.objective_higher_is_better else return_value
184185

185186
# include raw data in return if requested
186187
if self.return_raw is not None:

kernel_tuner/util.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,8 @@ def check_stop_criterion(to: dict) -> float:
205205
if "max_fevals" in to:
206206
if len(to.unique_results) >= to.max_fevals:
207207
raise StopCriterionReached(f"max_fevals ({to.max_fevals}) reached")
208-
return len(to.unique_results) / to.max_fevals
208+
if not "time_limit" in to:
209+
return len(to.unique_results) / to.max_fevals
209210
if "time_limit" in to:
210211
time_spent = (time.perf_counter() - to.start_time) + (to.simulated_time * 1e-3) + to.startup_time
211212
if time_spent > to.time_limit:

0 commit comments

Comments
 (0)