From b171aaba5a939a1bfe7bd8101d35300e519e7fdb Mon Sep 17 00:00:00 2001 From: Wilber Date: Mon, 27 Sep 2021 13:56:59 +0800 Subject: [PATCH] fix windows ut precession error (#36124) --- 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..2ff5d88300b 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, + const float epsilon = 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); + epsilon); } 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..5148c8039e6 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-3); // the analysis_output has some diff with native_output, // TODO(luotao): add CheckOutput for analysis_output later. -- GitLab