提交 ca52a93e 编写于 作者: M Megvii Engine Team 提交者: Xu Xinran

fix(mge/quant): fix init value of histogram observer

GitOrigin-RevId: 9c8caa5f8f2b02e881601a9aa6ff30f654e30a07
上级 9f352b1c
......@@ -194,7 +194,7 @@ class HistogramObserver(MinMaxObserver):
self.bins = bins
self.upsample_rate = upsample_rate
self.dst_nbins = _metadata_dict[dtype].qmax - _metadata_dict[dtype].qmin + 1
self.histogram = Buffer([0.0] * bins)
self.histogram = Buffer([-1] + [0.0] * (bins - 1))
def _non_linear_param_search(self):
r"""Non-linear parameter search.
......@@ -393,8 +393,7 @@ class HistogramObserver(MinMaxObserver):
histogram = self.histogram.numpy()
new_min = x.min()
new_max = x.max()
if min_val == 0 or max_val == 0:
if histogram[0] == -1:
new_histogram, _ = np.histogram(x, self.bins, (new_min, new_max))
else:
new_min = min(new_min, min_val)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册