20import onelib.constant
as _constant
24 return hasattr(args, attr)
and getattr(args, attr)
28 """make a command for running tf2tfliteV2.py"""
29 cmd = [sys.executable, os.path.expanduser(driver_path)]
32 cmd.append(
'--verbose')
35 cmd.append(getattr(args,
'model_format_cmd'))
37 cmd.append(
'--' + getattr(args,
'model_format'))
39 cmd.append(
'--graph_def')
43 cmd.append(
'--input_path')
44 cmd.append(os.path.expanduser(input_path))
47 cmd.append(
'--output_path')
48 cmd.append(os.path.expanduser(output_path))
51 cmd.append(
'--input_arrays')
52 cmd.append(getattr(args,
'input_arrays'))
55 cmd.append(
'--input_shapes')
56 cmd.append(getattr(args,
'input_shapes'))
59 cmd.append(
'--output_arrays')
60 cmd.append(getattr(args,
'output_arrays'))
63 if is_valid_attr(args,
'experimental_disable_batchmatmul_unfold'):
64 cmd.append(
'--experimental_disable_batchmatmul_unfold')
70 """make a command for running tflite2circle"""
71 cmd = [driver_path, input_path, output_path]
72 return [os.path.expanduser(c)
for c
in cmd]
76 """make a command for running circle2circle"""
77 cmd = [os.path.expanduser(c)
for c
in [driver_path, input_path, output_path]]
80 cmd.append(
'--generate_profile_data')
83 for opt
in _constant.CONSTANT.OPTIMIZATION_OPTS:
86 if type(getattr(args, opt[0]))
is bool:
87 cmd.append(
'--' + opt[0])
89 This condition check is for config file interface, usually would be
91 but user can write as follows while development
93 instead of removing SomeOption option
95 if type(getattr(args, opt[0]))
is str
and not getattr(
96 args, opt[0]).lower()
in [
'false',
'0',
'n']:
97 cmd.append(
'--' + opt[0])
is_valid_attr(args, attr)
make_circle2circle_cmd(args, driver_path, input_path, output_path)
make_tf2tfliteV2_cmd(args, driver_path, input_path, output_path)
make_tflite2circle_cmd(driver_path, input_path, output_path)