From 8f2d0e418e1c7c9c1e759e89397177c7fc0f13f9 Mon Sep 17 00:00:00 2001 From: Yanzhan Yang Date: Mon, 8 Jul 2019 15:17:41 +0800 Subject: [PATCH] fix quantification diff calculation error (#1733) --- tools/quantification/convert.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/tools/quantification/convert.cpp b/tools/quantification/convert.cpp index dc341d5d5a..606d2f5b93 100644 --- a/tools/quantification/convert.cpp +++ b/tools/quantification/convert.cpp @@ -336,7 +336,9 @@ void LoadWithDumpForFloat32(const paddle_mobile::framework::VarDesc &var_desc, c diff += abs(value - value_quantized); fwrite(&value_quantized, sizeof(float), 1, out_file); } - std::cout << "avg diff caused by quantization for var " << var_desc.Name() << " is: " << diff << std::endl; + if (memory_size > 0) { + std::cout << "avg diff caused by quantization for var " << var_desc.Name() << " is: " << (diff / memory_size) << std::endl; + } } void -- GitLab