ONE - On-device Neural Engine
Loading...
Searching...
No Matches
make_cmd Namespace Reference

Functions

 is_valid_attr (args, attr)
 
 make_tf2tfliteV2_cmd (args, driver_path, input_path, output_path)
 
 make_tflite2circle_cmd (driver_path, input_path, output_path)
 
 make_circle2circle_cmd (args, driver_path, input_path, output_path)
 

Function Documentation

◆ is_valid_attr()

make_cmd.is_valid_attr (   args,
  attr 
)

Definition at line 23 of file make_cmd.py.

23def is_valid_attr(args, attr):
24 return hasattr(args, attr) and getattr(args, attr)
25
26

Referenced by make_circle2circle_cmd(), and make_tf2tfliteV2_cmd().

◆ make_circle2circle_cmd()

make_cmd.make_circle2circle_cmd (   args,
  driver_path,
  input_path,
  output_path 
)
make a command for running circle2circle

Definition at line 81 of file make_cmd.py.

81def make_circle2circle_cmd(args, driver_path, input_path, output_path):
82 """make a command for running circle2circle"""
83 cmd = [os.path.expanduser(c) for c in [driver_path, input_path, output_path]]
84 # profiling
85 if is_valid_attr(args, 'generate_profile_data'):
86 cmd.append('--generate_profile_data')
87 # optimization pass(only true/false options)
88 # TODO support options whose number of arguments is more than zero
89 for opt in _constant.CONSTANT.OPTIMIZATION_OPTS:
90 if is_valid_attr(args, opt[0]):
91 # ./driver --opt[0]
92 if type(getattr(args, opt[0])) is bool:
93 cmd.append('--' + opt[0])
94 """
95 This condition check is for config file interface, usually would be
96 SomeOption=True
97 but user can write as follows while development
98 SomeOption=False
99 instead of removing SomeOption option
100 """
101 if type(getattr(args, opt[0])) is str and not getattr(
102 args, opt[0]).lower() in ['false', '0', 'n']:
103 cmd.append('--' + opt[0])
104
105 return cmd

References is_valid_attr().

◆ make_tf2tfliteV2_cmd()

make_cmd.make_tf2tfliteV2_cmd (   args,
  driver_path,
  input_path,
  output_path 
)
make a command for running tf2tfliteV2.py

Definition at line 27 of file make_cmd.py.

27def make_tf2tfliteV2_cmd(args, driver_path, input_path, output_path):
28 """make a command for running tf2tfliteV2.py"""
29 cmd = [sys.executable, os.path.expanduser(driver_path)]
30 # verbose
31 if is_valid_attr(args, 'verbose'):
32 cmd.append('--verbose')
33 # model_format
34 if is_valid_attr(args, 'model_format_cmd'):
35 cmd.append(getattr(args, 'model_format_cmd'))
36 elif is_valid_attr(args, 'model_format'):
37 cmd.append('--' + getattr(args, 'model_format'))
38 else:
39 cmd.append('--graph_def') # default value
40 # converter version
41 if is_valid_attr(args, 'converter_version_cmd'):
42 cmd.append(getattr(args, 'converter_version_cmd'))
43 elif is_valid_attr(args, 'converter_version'):
44 cmd.append('--' + getattr(args, 'converter_version'))
45 else:
46 cmd.append('--v1') # default value
47 # input_path
48 if is_valid_attr(args, 'input_path'):
49 cmd.append('--input_path')
50 cmd.append(os.path.expanduser(input_path))
51 # output_path
52 if is_valid_attr(args, 'output_path'):
53 cmd.append('--output_path')
54 cmd.append(os.path.expanduser(output_path))
55 # input_arrays
56 if is_valid_attr(args, 'input_arrays'):
57 cmd.append('--input_arrays')
58 cmd.append(getattr(args, 'input_arrays'))
59 # input_shapes
60 if is_valid_attr(args, 'input_shapes'):
61 cmd.append('--input_shapes')
62 cmd.append(getattr(args, 'input_shapes'))
63 # output_arrays
64 if is_valid_attr(args, 'output_arrays'):
65 cmd.append('--output_arrays')
66 cmd.append(getattr(args, 'output_arrays'))
67
68 # experimental options
69 if is_valid_attr(args, 'experimental_disable_batchmatmul_unfold'):
70 cmd.append('--experimental_disable_batchmatmul_unfold')
71
72 return cmd
73
74

References is_valid_attr().

◆ make_tflite2circle_cmd()

make_cmd.make_tflite2circle_cmd (   driver_path,
  input_path,
  output_path 
)
make a command for running tflite2circle

Definition at line 75 of file make_cmd.py.

75def make_tflite2circle_cmd(driver_path, input_path, output_path):
76 """make a command for running tflite2circle"""
77 cmd = [driver_path, input_path, output_path]
78 return [os.path.expanduser(c) for c in cmd]
79
80