1from __future__
import print_function
24helpstr =
"Expected arguments: -b <path_to_nnkit>" + \
26 "-t <testcases_dir> " + \
27 "[-p <nporc> <proc_num>] " + \
29 "(<tflite_model_file> | <caffe_prototxt_model> <caffe_caffemodel_file>)"
33 print(*args, file=sys.stderr, **kwargs)
49 elif arg ==
'-b' or arg ==
'-f' or arg ==
'-t':
51 eprint(arg,
" is missing it's value")
54 args[arg] = sys.argv[i + 1]
58 eprint(arg,
" is missing some of it's values")
61 args[arg] = (int(sys.argv[i + 1]), int(sys.argv[i + 2]))
63 print(
'Unsupported argument: ', arg)
66if not (
'-b' in args
and '-f' in args
and '-t' in args):
67 eprint(
'Some arguments are not provided')
72build_path = args[
'-b']
73testcases_dir = args[
'-t']
74nproc, proc_num = args[
'-p']
75remove_existing = args[
'-r']
79 print(
'Model: ', model)
81 model_proto = sys.argv[-2]
82 model_caffe = sys.argv[-1]
83 print(
'Models: ', model_proto, model_caffe)
85 eprint(
'Unsupported framework:', fw)
88eprint(
'started at', datetime.datetime.now())
89print(
'Framework: ', fw)
90print(
'Path to nnkit: ', build_path)
91print(
'Testcases folder: ', testcases_dir)
99 build_path +
"/tools/run/nnkit-run",
"--pre",
100 build_path +
"/actions/HDF5/libnnkit_HDF5_import_action.so",
"--pre-arg",
101 infilename,
"--backend", build_path +
"/backends/caffe/libnnkit_caffe_backend.so",
102 "--backend-arg", proto,
"--backend-arg", caffemodel,
"--post",
103 build_path +
"/actions/HDF5/libnnkit_HDF5_export_action.so",
"--post-arg",
110 build_path +
"/tools/run/nnkit-run",
"--pre",
111 build_path +
"/actions/HDF5/libnnkit_HDF5_import_action.so",
"--pre-arg",
112 infilename,
"--backend",
113 build_path +
"/backends/tflite/libnnkit_tflite_backend.so",
"--backend-arg",
114 model_file,
"--post", build_path +
"/actions/builtin/libnnkit_show_action.so",
115 "--post", build_path +
"/actions/HDF5/libnnkit_HDF5_export_action.so",
116 "--post-arg", outfilename
121testcases = glob.glob(testcases_dir +
'/testcase*')
128testcases = testcases[proc_num - 1::nproc]
131for testcase
in testcases:
134 infile = glob.glob(testcase +
'/input/*' + hdf_suffix)
137 outfile = testcase +
'/output/output' + hdf_suffix
138 outfile_bin = testcase +
'/output/output' + bin_suffix
139 if len(glob.glob(outfile)) == 0
or remove_existing:
145 subprocess.call(command)
146 if len(glob.glob(outfile_bin)) == 0
or remove_existing:
148 eprint(testcase_num,
"/", len(testcases))
150 eprint(testcase,
': input not found')
152 eprint(testcase,
'failed')
154eprint(
'ended at', datetime.datetime.now())
get_command_tfl(infilename, outfilename, model_file)
get_command_caf(infilename, outfilename, proto, caffemodel)
res2bin(infilename, outfilename)