ONE - On-device Neural Engine
Loading...
Searching...
No Matches
QErrorComputer.MSEComputer Class Reference
Collaboration diagram for QErrorComputer.MSEComputer:

Public Member Functions

 __init__ (self, fp32_dir, fq_dir)
 
 advance_on (self, fp32_dir, fq_dir)
 
 get_final_result (self)
 
 run (self)
 
- Public Member Functions inherited from QErrorComputer.QErrorComputer
 collect_data_path (self, fp32_dir, fq_dir)
 

Data Fields

 qerror_min
 
 qerror_max
 
- Data Fields inherited from QErrorComputer.QErrorComputer
 qerror_map
 

Protected Attributes

 _fp32_dir
 
 _fq_dir
 
- Protected Attributes inherited from QErrorComputer.QErrorComputer
 _fp32_dir
 
 _fq_dir
 
 _num_processed_data
 
 _num_data
 
 _tid_to_tname
 

Detailed Description

Definition at line 135 of file QErrorComputer.py.

Constructor & Destructor Documentation

◆ __init__()

QErrorComputer.MSEComputer.__init__ (   self,
  fp32_dir,
  fq_dir 
)

Reimplemented from QErrorComputer.QErrorComputer.

Definition at line 136 of file QErrorComputer.py.

136 def __init__(self, fp32_dir, fq_dir):
137 super().__init__(fp32_dir, fq_dir)
138 self.qerror_min = float('inf')
139 self.qerror_max = -self.qerror_min
140

References QErrorComputer.MSEComputer.__init__().

Referenced by QErrorComputer.MSEComputer.__init__().

Member Function Documentation

◆ advance_on()

QErrorComputer.MSEComputer.advance_on (   self,
  fp32_dir,
  fq_dir 
)

Definition at line 142 of file QErrorComputer.py.

142 def advance_on(self, fp32_dir, fq_dir):
143 data_paths = self.collect_data_path(fp32_dir, fq_dir)
144 for tensor_name, data_path in data_paths.items():
145 for (fp32_data_path, fq_data_path) in data_path:
146 fp32_data = np.load(fp32_data_path)
147 fq_data = np.load(fq_data_path)
148
149 MSE = np.square(fp32_data - fq_data).mean()
150
151 self.qerror_map[tensor_name] += MSE
152
153 self.qerror_min = min(MSE, self.qerror_min)
154 self.qerror_max = max(MSE, self.qerror_max)
155

References QErrorComputer.QErrorComputer.collect_data_path(), QErrorComputer.QErrorComputer.qerror_map, QErrorComputer.MSEComputer.qerror_max, QErrorComputer.TAEComputer.qerror_max, QErrorComputer.MSEComputer.qerror_min, and QErrorComputer.TAEComputer.qerror_min.

◆ get_final_result()

QErrorComputer.MSEComputer.get_final_result (   self)

Definition at line 160 of file QErrorComputer.py.

160 def get_final_result(self):
161 qerror_map = dict()
162 for tensor_name, acc in self.qerror_map.items():
163 qerror_map[tensor_name] = acc / self._num_processed_data
164
165 return qerror_map, self.qerror_min, self.qerror_max
166

References QErrorComputer.QErrorComputer._num_processed_data, QErrorComputer.QErrorComputer.qerror_map, QErrorComputer.MSEComputer.qerror_max, QErrorComputer.TAEComputer.qerror_max, QErrorComputer.MSEComputer.qerror_min, and QErrorComputer.TAEComputer.qerror_min.

◆ run()

QErrorComputer.MSEComputer.run (   self)
Return qerror map (dict: tensor_name(string) -> qerror(float)).

Reimplemented from QErrorComputer.QErrorComputer.

Definition at line 167 of file QErrorComputer.py.

167 def run(self):
168 self.advance_on(self._fp32_dir, self._fq_dir)
169 return self.get_final_result()
170
171
void run(std::ofstream &os, const circle::Model *model)

Field Documentation

◆ _fp32_dir

QErrorComputer.MSEComputer._fp32_dir
protected

Definition at line 168 of file QErrorComputer.py.

◆ _fq_dir

QErrorComputer.MSEComputer._fq_dir
protected

Definition at line 168 of file QErrorComputer.py.

◆ qerror_max

◆ qerror_min


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