Skip to content

Commit 5b6a0be

Browse files
committed
Improved the detection of whether an interval can be used
1 parent 160a81f commit 5b6a0be

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

kernel_tuner/util.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -444,6 +444,8 @@ def get_instance_string(params):
444444

445445
def get_interval(a: list):
446446
"""Checks if an array can be an interval. Returns (start, end, step) if interval, otherwise None."""
447+
if len(a) < 3:
448+
return None
447449
if not all(isinstance(e, (int, float)) for e in a):
448450
return None
449451
a_min = min(a)
@@ -456,7 +458,10 @@ def get_interval(a: list):
456458
for i, e in enumerate(a):
457459
if e-a[i-1] != step:
458460
return None
459-
return (a_min, a_max, step)
461+
result = (a_min, a_max, step)
462+
if not all(isinstance(e, (int, float)) for e in result):
463+
return None
464+
return result
460465

461466

462467
def get_kernel_string(kernel_source, params=None):

0 commit comments

Comments
 (0)