From efddf9ea9a319a361ecb2ad4030b15355f53c061 Mon Sep 17 00:00:00 2001 From: baoachun <962571062@qq.com> Date: Thu, 21 Apr 2022 10:16:41 +0800 Subject: [PATCH] update demo_ci ut threshold (#41981) (#42030) --- paddle/fluid/inference/api/demo_ci/utils.h | 5 +++-- paddle/fluid/inference/api/demo_ci/vis_demo.cc | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/inference/api/demo_ci/utils.h b/paddle/fluid/inference/api/demo_ci/utils.h index 5ac00fd294f..b4f40194aa9 100644 --- a/paddle/fluid/inference/api/demo_ci/utils.h +++ b/paddle/fluid/inference/api/demo_ci/utils.h @@ -71,7 +71,8 @@ Record ProcessALine(const std::string& line) { return record; } -void CheckOutput(const std::string& referfile, const PaddleTensor& output) { +void CheckOutput(const std::string& referfile, const PaddleTensor& output, + float threshold = 1e-5) { std::string line; std::ifstream file(referfile); std::getline(file, line); @@ -93,7 +94,7 @@ void CheckOutput(const std::string& referfile, const PaddleTensor& output) { for (size_t i = 0; i < numel; ++i) { CHECK_LT( fabs(static_cast(output.data.data())[i] - refer.data[i]), - 1e-5); + threshold); } break; } diff --git a/paddle/fluid/inference/api/demo_ci/vis_demo.cc b/paddle/fluid/inference/api/demo_ci/vis_demo.cc index 0b3257da92c..818444fbcb6 100644 --- a/paddle/fluid/inference/api/demo_ci/vis_demo.cc +++ b/paddle/fluid/inference/api/demo_ci/vis_demo.cc @@ -71,7 +71,7 @@ void Main(bool use_gpu) { auto& tensor = output.front(); // compare with reference result - CheckOutput(FLAGS_refer, tensor); + CheckOutput(FLAGS_refer, tensor, 1e-4); // the analysis_output has some diff with native_output, // TODO(luotao): add CheckOutput for analysis_output later. -- GitLab