-
Notifications
You must be signed in to change notification settings - Fork 23
/
ch2ocheck.py
executable file
·46 lines (36 loc) · 1.07 KB
/
ch2ocheck.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#!/usr/bin/python
#
# Example usage:
#
# $ python3 scripts/ch2ocheck.py testcases/ch2o_tests/node/Linear.py
import glob
import os
import shutil
import subprocess
import sys
def main():
if len(sys.argv) == 1:
sys.stderr.write('Usage: %s test.py\n' % sys.argv[0])
sys.exit(1)
os.environ['PYTHONPATH'] = '.'
py = sys.argv[1]
tmpdir = 'out/ch2o_tmp'
if os.path.exists(tmpdir):
shutil.rmtree(tmpdir)
os.makedirs(tmpdir)
subprocess.check_call([sys.executable, py, os.path.join(tmpdir, 'tmp')])
if os.path.exists('build/CMakeCache.txt'):
build_dir = 'build'
elif os.path.exists('CMakeCache.txt'):
build_dir = '.'
else:
build_dir = 'build'
run_onnx = os.path.join(build_dir, 'tools/run_onnx')
for test in sorted(glob.glob(os.path.join(tmpdir, '*'))):
print('*** Testing %s ***' % test)
args = [run_onnx, '--test', test] + sys.argv[2:]
if 'backprop' in test:
args.append('--backprop')
print(' '.join(args))
subprocess.check_call(args)
main()