Skip to content

Commit e9d1256

Browse files
committed
revise fastmath script and add support for reading arg from command line
1 parent 280eb9b commit e9d1256

File tree

3 files changed

+50
-20
lines changed

3 files changed

+50
-20
lines changed

check_fastmath.py

Lines changed: 0 additions & 17 deletions
This file was deleted.

fastmath.py

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#!/usr/bin/env python
2+
3+
import argparse
4+
import importlib
5+
6+
from stumpy.cache import get_njit_funcs
7+
8+
9+
def check_fastmath():
10+
"""
11+
Check if all njit functions have the `fastmath` flag set
12+
13+
Parameters
14+
----------
15+
None
16+
17+
Returns
18+
-------
19+
None
20+
"""
21+
missing_fastmath = [] # list of njit functions with missing fastmath flags
22+
for module_name, func_name in get_njit_funcs():
23+
module = importlib.import_module(f".{module_name}", package="stumpy")
24+
func = getattr(module, func_name)
25+
if "fastmath" not in func.targetoptions.keys():
26+
missing_fastmath.append(f"{module_name}.{func_name}")
27+
28+
if len(missing_fastmath) > 0:
29+
msg = "Found one or more functions that are missing the `fastmath` flag. "
30+
msg += f"The function(s) are:\n {missing_fastmath}\n"
31+
raise ValueError(msg)
32+
33+
return
34+
35+
36+
parser = argparse.ArgumentParser()
37+
parser.add_argument("--perform", required=True)
38+
EXCEPTED_VALUES = ["check"]
39+
40+
args = parser.parse_args()
41+
if args.perform not in EXCEPTED_VALUES:
42+
raise ValueError("Invalid argument")
43+
44+
if args.perform == "check":
45+
check_fastmath()
46+
else:
47+
pass

test.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,10 @@ check_print()
9393
fi
9494
}
9595

96-
check_fastmath()
96+
fastmath()
9797
{
9898
echo "Checking Missing fastmath flags in njit functions"
99-
./check_fastmath.py
99+
./fastmath.py --perform check
100100
check_errs $?
101101
}
102102

@@ -342,7 +342,7 @@ check_ray
342342

343343

344344
if [[ ! -z $NUMBA_DISABLE_JIT && ${NUMBA_DISABLE_JIT} -eq "0" ]]; then
345-
check_fastmath
345+
fastmath
346346
fi
347347

348348

0 commit comments

Comments
 (0)