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

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)
 

Protected Attributes

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

Additional Inherited Members

- Data Fields inherited from QErrorComputer.QErrorComputer
 qerror_map
 

Detailed Description

Definition at line 90 of file QErrorComputer.py.

Constructor & Destructor Documentation

◆ __init__()

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

Reimplemented from QErrorComputer.QErrorComputer.

Definition at line 91 of file QErrorComputer.py.

91 def __init__(self, fp32_dir, fq_dir):
92 super().__init__(fp32_dir, fq_dir)
93

References QErrorComputer.MPEIRComputer.__init__().

Referenced by QErrorComputer.MPEIRComputer.__init__().

Member Function Documentation

◆ advance_on()

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

Definition at line 95 of file QErrorComputer.py.

95 def advance_on(self, fp32_dir, fq_dir):
96 data_paths = self.collect_data_path(fp32_dir, fq_dir)
97 for tensor_name, data_path in data_paths.items():
98 for (fp32_data_path, fq_data_path) in data_path:
99 fp32_data = np.load(fp32_data_path)
100 fq_data = np.load(fq_data_path)
101
102 diff = np.absolute(fp32_data - fq_data).reshape(-1)
103
104 fp32_min = np.min(fp32_data.reshape(-1))
105 fp32_max = np.max(fp32_data.reshape(-1))
106
107 # Peak Error-to-Interval Ratio (PEIR)
108 # NOTE: PEIR is an analogue of PSNR (Peak Signal to Noise Ratio)
109 PEAK_ERROR = np.max(diff)
110 INTERVAL = fp32_max - fp32_min
111
112 # If INTERVAL is 0, PEIR becomes NaN.
113 # To prevent this, relaxed PEIR with epsilon(10^(-6)) is used.
114 rPEIR = PEAK_ERROR / (INTERVAL + 0.000001)
115
116 self.qerror_map[tensor_name] += rPEIR
117

References QErrorComputer.QErrorComputer.collect_data_path(), and QErrorComputer.QErrorComputer.qerror_map.

◆ get_final_result()

QErrorComputer.MPEIRComputer.get_final_result (   self)

Definition at line 122 of file QErrorComputer.py.

122 def get_final_result(self):
123 qerror_map = dict()
124 for tensor_name, acc in self.qerror_map.items():
125 qerror_map[tensor_name] = acc / self._num_processed_data
126
127 # Fixed qerror_min (0), qerror_max (1)
128 return qerror_map, 0.0, 1.0
129

References QErrorComputer.QErrorComputer._num_processed_data, and QErrorComputer.QErrorComputer.qerror_map.

◆ run()

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

Reimplemented from QErrorComputer.QErrorComputer.

Definition at line 130 of file QErrorComputer.py.

130 def run(self):
131 self.advance_on(self._fp32_dir, self._fq_dir)
132 return self.get_final_result()
133
134
void run(std::ofstream &os, const circle::Model *model)

Field Documentation

◆ _fp32_dir

QErrorComputer.MPEIRComputer._fp32_dir
protected

Definition at line 131 of file QErrorComputer.py.

◆ _fq_dir

QErrorComputer.MPEIRComputer._fq_dir
protected

Definition at line 131 of file QErrorComputer.py.


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