From d861a61990155e9431c5cc3c898afdedaf765f84 Mon Sep 17 00:00:00 2001 From: xutianchun Date: Mon, 24 Aug 2020 17:54:34 +0800 Subject: [PATCH] Fix Post Training Log --- mindspore/lite/tools/anf_exporter/anf_exporter.cc | 9 ++++++++- .../lite/tools/converter/quantizer/quantize_util.cc | 4 ++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/mindspore/lite/tools/anf_exporter/anf_exporter.cc b/mindspore/lite/tools/anf_exporter/anf_exporter.cc index f74800bc7a..8e584ebe04 100644 --- a/mindspore/lite/tools/anf_exporter/anf_exporter.cc +++ b/mindspore/lite/tools/anf_exporter/anf_exporter.cc @@ -69,6 +69,10 @@ int AnfExporter::ConvertQuantParam(const std::unique_ptr &me // activation auto input_quant_params = primitive->GetInputQuantParams(); auto node_type = (schema::PrimitiveType)primitive->Type(); + if (input_quant_params.empty()) { + MS_LOG(ERROR) << "node: " << dst_node->name << " input quant params is empty"; + return RET_ERROR; + } for (size_t i = 0; i < input_quant_params.size(); i++) { if (i >= dst_node->inputIndex.size()) { MS_LOG(ERROR) << "node: " << dst_node->name << " input has " << input_quant_params.size() @@ -93,7 +97,10 @@ int AnfExporter::ConvertQuantParam(const std::unique_ptr &me auto tensor_output = meta_graph->allTensors[output_index].get(); auto output_quant_params = primitive->GetOutputQuantParams(); if (output_quant_params.empty()) { - MS_LOG(WARNING) << "node: " << dst_node->name << " output quant params is empty"; + if (node_type != schema::PrimitiveType_QuantDTypeCast) { + MS_LOG(ERROR) << "node: " << dst_node->name << " output quant params is empty"; + return RET_ERROR; + } } else { for (auto output_quant_param : output_quant_params[0]) { if (tensor_output->quantParams.empty()) { diff --git a/mindspore/lite/tools/converter/quantizer/quantize_util.cc b/mindspore/lite/tools/converter/quantizer/quantize_util.cc index e61e942910..6e7690de3a 100644 --- a/mindspore/lite/tools/converter/quantizer/quantize_util.cc +++ b/mindspore/lite/tools/converter/quantizer/quantize_util.cc @@ -168,11 +168,11 @@ STATUS CalQuantizationParams(schema::QuantParamT *quantParam, double mMin, doubl int quant_max, int quant_min, int num_bits) { MS_ASSERT(quantParam != nullptr); if (mMin > 0.0f) { - MS_LOG(ERROR) << "min " << mMin << " is bigger then 0, set to 0, this may course low precision"; + MS_LOG(DEBUG) << "min " << mMin << " is bigger then 0, set to 0, this may course low precision"; mMin = 0.0f; } if (mMax < 0.0f) { - MS_LOG(ERROR) << "mMax " << mMax << " is smaller than 0, set to 0, this may course low precision"; + MS_LOG(DEBUG) << "mMax " << mMax << " is smaller than 0, set to 0, this may course low precision"; mMax = 0.0f; } if (mMin > mMax) {