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 75 of file make_cmd.py.

75def make_circle2circle_cmd(args, driver_path, input_path, output_path):
76 """make a command for running circle2circle"""
77 cmd = [os.path.expanduser(c) for c in [driver_path, input_path, output_path]]
78 # profiling
79 if is_valid_attr(args, 'generate_profile_data'):
80 cmd.append('--generate_profile_data')
81 # optimization pass(only true/false options)
82 # TODO support options whose number of arguments is more than zero
83 for opt in _constant.CONSTANT.OPTIMIZATION_OPTS:
84 if is_valid_attr(args, opt[0]):
85 # ./driver --opt[0]
86 if type(getattr(args, opt[0])) is bool:
87 cmd.append('--' + opt[0])
88 """
89 This condition check is for config file interface, usually would be
90 SomeOption=True
91 but user can write as follows while development
92 SomeOption=False
93 instead of removing SomeOption option
94 """
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])
98
99 return cmd
int32_t type

References is_valid_attr(), and type.

◆ 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 # NOTE converter_version_cmd is removed as it is deprecated
41 # input_path
42 if is_valid_attr(args, 'input_path'):
43 cmd.append('--input_path')
44 cmd.append(os.path.expanduser(input_path))
45 # output_path
46 if is_valid_attr(args, 'output_path'):
47 cmd.append('--output_path')
48 cmd.append(os.path.expanduser(output_path))
49 # input_arrays
50 if is_valid_attr(args, 'input_arrays'):
51 cmd.append('--input_arrays')
52 cmd.append(getattr(args, 'input_arrays'))
53 # input_shapes
54 if is_valid_attr(args, 'input_shapes'):
55 cmd.append('--input_shapes')
56 cmd.append(getattr(args, 'input_shapes'))
57 # output_arrays
58 if is_valid_attr(args, 'output_arrays'):
59 cmd.append('--output_arrays')
60 cmd.append(getattr(args, 'output_arrays'))
61
62 # experimental options
63 if is_valid_attr(args, 'experimental_disable_batchmatmul_unfold'):
64 cmd.append('--experimental_disable_batchmatmul_unfold')
65
66 return cmd
67
68

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 69 of file make_cmd.py.

69def make_tflite2circle_cmd(driver_path, input_path, output_path):
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]
73
74