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

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

 total_error
 
 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 172 of file QErrorComputer.py.

Constructor & Destructor Documentation

◆ __init__()

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

Reimplemented from QErrorComputer.QErrorComputer.

Definition at line 173 of file QErrorComputer.py.

173 def __init__(self, fp32_dir, fq_dir):
174 super().__init__(fp32_dir, fq_dir)
175 self.total_error = 0
176 self.qerror_min = float('inf')
177 self.qerror_max = -self.qerror_min
178

References QErrorComputer.TAEComputer.__init__().

Referenced by QErrorComputer.TAEComputer.__init__().

Member Function Documentation

◆ advance_on()

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

Definition at line 179 of file QErrorComputer.py.

179 def advance_on(self, fp32_dir, fq_dir):
180 data_paths = self.collect_data_path(fp32_dir, fq_dir)
181 for tensor_name, data_path in data_paths.items():
182 for (fp32_data_path, fq_data_path) in data_path:
183 fp32_data = np.load(fp32_data_path)
184 fq_data = np.load(fq_data_path)
185
186 total_error = np.sum(np.abs(fp32_data - fq_data))
187
188 self.qerror_map[tensor_name] += total_error
189
190 self.qerror_min = min(total_error, self.qerror_min)
191 self.qerror_max = max(total_error, self.qerror_max)
192

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.TAEComputer.get_final_result (   self)

Definition at line 197 of file QErrorComputer.py.

197 def get_final_result(self):
198 qerror_map = dict()
199 for tensor_name, acc in self.qerror_map.items():
200 qerror_map[tensor_name] = acc / self._num_processed_data
201 return qerror_map, self.qerror_min, self.qerror_max
202

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.TAEComputer.run (   self)
Return qerror map (dict: tensor_name(string) -> qerror(float)).

Reimplemented from QErrorComputer.QErrorComputer.

Definition at line 203 of file QErrorComputer.py.

203 def run(self):
204 self.advance_on(self._fp32_dir, self._fq_dir)
205 return self.get_final_result()
206
207
208# Scaled Root Mean Square Error (SRMSE)
209# SRMSE = sqrt(MSE) / scale
void run(std::ofstream &os, const circle::Model *model)

Field Documentation

◆ _fp32_dir

QErrorComputer.TAEComputer._fp32_dir
protected

Definition at line 204 of file QErrorComputer.py.

◆ _fq_dir

QErrorComputer.TAEComputer._fq_dir
protected

Definition at line 204 of file QErrorComputer.py.

◆ qerror_max

◆ qerror_min

◆ total_error

QErrorComputer.TAEComputer.total_error

Definition at line 175 of file QErrorComputer.py.


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