ONE - On-device Neural Engine
Loading...
Searching...
No Matches
OptionBuilder.OptionBuilder Class Reference

Public Member Functions

 __init__ (self, one_cmd_type)
 
 build (self, commands)
 

Data Fields

 type
 

Protected Member Functions

 _build_default (self, commands)
 
 _build_with_unknown_command (self, commands)
 
 _build_import (self, commands)
 
 _build_optimize (self, commands)
 
 _build_quantize (self, commands)
 

Protected Attributes

 _build_default
 

Detailed Description

Definition at line 20 of file OptionBuilder.py.

Constructor & Destructor Documentation

◆ __init__()

OptionBuilder.OptionBuilder.__init__ (   self,
  one_cmd_type 
)

Definition at line 21 of file OptionBuilder.py.

21 def __init__(self, one_cmd_type):
22 self.type = one_cmd_type
23

Member Function Documentation

◆ _build_default()

OptionBuilder.OptionBuilder._build_default (   self,
  commands 
)
protected

Definition at line 24 of file OptionBuilder.py.

24 def _build_default(self, commands):
25 options = []
26 for k, v in commands.items():
27 options.extend(['--' + k, v])
28 return options
29

◆ _build_import()

OptionBuilder.OptionBuilder._build_import (   self,
  commands 
)
protected

Definition at line 41 of file OptionBuilder.py.

41 def _build_import(self, commands):
42 options = []
43 arg_0 = ['save_intermediate']
44 for k, v in commands.items():
45 if k in arg_0 and v == "True":
46 options.extend(['--' + k])
47 continue
48 options.extend(['--' + k, v])
49 return options
50

◆ _build_optimize()

OptionBuilder.OptionBuilder._build_optimize (   self,
  commands 
)
protected

Definition at line 51 of file OptionBuilder.py.

51 def _build_optimize(self, commands):
52 options = []
53 arg_0 = ['generate_profile_data']
54 arg_1 = ['input_path', 'output_path', 'change_outputs']
55 for k, v in commands.items():
56 if k in arg_1:
57 options.extend(['--' + k, v])
58 continue
59 if k in arg_0 and v == 'True':
60 options.extend(['--' + k])
61 continue
62 for opt in CONSTANT.OPTIMIZATION_OPTS:
63 if k == opt[0] and v == "True":
64 options.extend(['--' + k])
65 break
66 return options
67

◆ _build_quantize()

OptionBuilder.OptionBuilder._build_quantize (   self,
  commands 
)
protected

Definition at line 68 of file OptionBuilder.py.

68 def _build_quantize(self, commands):
69 options = []
70 arg_0 = [
71 'generate_profile_data', 'save_intermediate', 'TF-style_maxpool',
72 'evaluate_result', 'print_mae', 'print_mape', 'print_mpeir',
73 'print_top1_match', 'print_top5_match', 'force_quantparam', 'copy_quantparam'
74 ]
75 for k, v in commands.items():
76 if k in arg_0 and v == "True":
77 options.extend(['--' + k])
78 continue
79 options.extend(['--' + k, v])
80 return options
81

◆ _build_with_unknown_command()

OptionBuilder.OptionBuilder._build_with_unknown_command (   self,
  commands 
)
protected

Definition at line 30 of file OptionBuilder.py.

30 def _build_with_unknown_command(self, commands):
31 COMMAND_K = 'command'
32 options = []
33 for k, v in commands.items():
34 if k == COMMAND_K:
35 continue
36 options.extend(['--' + k, v])
37 options.extend(['--'])
38 options.extend(commands[COMMAND_K].split())
39 return options
40

◆ build()

OptionBuilder.OptionBuilder.build (   self,
  commands 
)

Definition at line 82 of file OptionBuilder.py.

82 def build(self, commands):
83 cmd_book = dict.fromkeys(
84 ['one-import-bcq', 'one-import-tflite', 'one-pack', 'one-partition'],
85 self._build_default)
86 cmd_book['one-codegen'] = self._build_with_unknown_command
87 cmd_book['one-import-onnx'] = self._build_import
88 cmd_book['one-import-pytorch'] = self._build_import
89 cmd_book['one-import-tf'] = self._build_import
90 cmd_book['one-infer'] = self._build_with_unknown_command
91 cmd_book['one-optimize'] = self._build_optimize
92 cmd_book['one-profile'] = self._build_with_unknown_command
93 cmd_book['one-quantize'] = self._build_quantize
94
95 return cmd_book[self.type](commands)

Field Documentation

◆ _build_default

OptionBuilder.OptionBuilder._build_default
protected

Definition at line 85 of file OptionBuilder.py.

◆ type

OptionBuilder.OptionBuilder.type

Definition at line 22 of file OptionBuilder.py.


The documentation for this class was generated from the following file: