diff --git a/mindspore/train/quant/quant.py b/mindspore/train/quant/quant.py index 1a2b1b4a4c..78ffc00f94 100644 --- a/mindspore/train/quant/quant.py +++ b/mindspore/train/quant/quant.py @@ -342,14 +342,6 @@ class ExportToQuantInferNetwork: network = self._convert_quant2deploy(network) return network - def statistic_weight(self, weight): - out_nums = np.shape(weight)[0] - sta_metric = np.zeros((out_nums, 2), dtype=np.float32) - for num in range(out_nums): - sta_metric[num, 0] = np.min(weight[num]) - sta_metric[num, 1] = np.max(weight[num]) - return np.mean(sta_metric[:, 1]).tolist(), np.mean(sta_metric[:, 0]).tolist() - def _get_quant_block(self, cell_core, activation, fake_quant_a_out): """convet network's quant subcell to deploy subcell""" # Calculate the scale and zero point @@ -410,7 +402,8 @@ class ExportToQuantInferNetwork: elif isinstance(cell_core, quant.Conv2dBnWithoutFoldQuant): weight, bias = quant_utils.without_fold_batchnorm(weight, cell_core) if self.is_mindir: - param_dict["filter_maxq"], param_dict["filter_minq"] = self.statistic_weight(weight) + param_dict["filter_maxq"], param_dict["filter_minq"] = cell_core.fake_quant_weight.maxq, \ + cell_core.fake_quant_weight.minq weight_b = weight bias_b = bias # apply the quant