22from test_utils
import TestRunner
23from q_implant_validator
import validate
25parser = argparse.ArgumentParser()
26parser.add_argument(
'--input_dir', type=str, required=
True)
27parser.add_argument(
'--output_dir', type=str, required=
True)
28parser.add_argument(
'--driver', type=str, required=
True)
29parser.add_argument(
'--dump', type=str, required=
True)
30parser.add_argument(
'--model', type=str, required=
True)
31args = parser.parse_args()
33input_dir = args.input_dir
34output_dir = args.output_dir
39module = importlib.import_module(
'qparam.' + model)
41input_circle = input_dir +
'.circle'
42output_circle = output_dir + f
'/{module._name_}/output.circle'
43qparam_dir = output_dir + f
'/{module._name_}/qparam.json'
44h5_path = output_dir + f
'/{module._name_}/output.h5'
46if not os.path.exists(input_circle):
47 print(
'fail to load input circle')
51if os.path.exists(output_circle):
52 os.remove(output_circle)
54if os.path.exists(h5_path):
60test_runner.register(module._test_case_)
64if not os.path.exists(qparam_dir):
65 print(
'qparam generate fail')
69process = subprocess.run([driver, input_circle, qparam_dir, output_circle], check=
True)
72 process.check_returncode()
74 print(
'q-implant run failed')
77if not os.path.exists(output_circle):
78 print(
'output circle generate fail')
82process = subprocess.run([dump,
'--tensors_to_hdf5', h5_path, output_circle], check=
True)
85 process.check_returncode()
87 print(
'circle-tensordump run failed')
90if not os.path.exists(h5_path):
91 print(
'h5 dump failed')
94if not validate(h5_path, output_dir + f
'/{module._name_}', qparam_dir):