From f856fc8d750a18793394eab02afd596721885cba Mon Sep 17 00:00:00 2001 From: Wangzheee <634486483@qq.com> Date: Thu, 13 Oct 2022 18:48:28 +0800 Subject: [PATCH] test=infer-coverage (#46983) --- .../tests/api/analyzer_bert_tester.cc | 23 +++++++++++-- .../tests/api/analyzer_ernie_tester.cc | 33 +++++++++++++++++-- 2 files changed, 51 insertions(+), 5 deletions(-) diff --git a/paddle/fluid/inference/tests/api/analyzer_bert_tester.cc b/paddle/fluid/inference/tests/api/analyzer_bert_tester.cc index 727d2576e5..db1f2953c7 100644 --- a/paddle/fluid/inference/tests/api/analyzer_bert_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_bert_tester.cc @@ -40,7 +40,12 @@ T GetValueFromStream(std::stringstream &ss); template <> std::string GetValueFromStream(std::stringstream &ss); -TEST(Analyzer_bert, profile) { profile(); } +TEST(Analyzer_bert, profile) { +#if !defined(_WIN32) + setenv("NVIDIA_TF32_OVERRIDE", "0", 1); +#endif + profile(); +} #ifdef PADDLE_WITH_MKLDNN TEST(Analyzer_bert, profile_mkldnn) { @@ -57,6 +62,9 @@ TEST(Analyzer_bert, profile_mkldnn_bf16) { // Check the fuse status TEST(Analyzer_bert, fuse_statis) { +#if !defined(_WIN32) + setenv("NVIDIA_TF32_OVERRIDE", "0", 1); +#endif auto cfg(SetConfig()); int num_ops; auto predictor = CreatePaddlePredictor(cfg); @@ -65,7 +73,12 @@ TEST(Analyzer_bert, fuse_statis) { LOG(INFO) << "num_ops: " << num_ops; } -TEST(Analyzer_bert, compare) { CompareNativeAndAnalysisWrapper(); } +TEST(Analyzer_bert, compare) { +#if !defined(_WIN32) + setenv("NVIDIA_TF32_OVERRIDE", "0", 1); +#endif + CompareNativeAndAnalysisWrapper(); +} #ifdef PADDLE_WITH_MKLDNN TEST(Analyzer_bert, compare_mkldnn) { auto use_mkldnn = true; @@ -75,6 +88,9 @@ TEST(Analyzer_bert, compare_mkldnn) { // Compare Deterministic result TEST(Analyzer_bert, compare_determine) { +#if !defined(_WIN32) + setenv("NVIDIA_TF32_OVERRIDE", "0", 1); +#endif auto cfg(SetConfig()); auto inputs = LoadInputData(); @@ -83,6 +99,9 @@ TEST(Analyzer_bert, compare_determine) { } TEST(Analyzer_bert, transfer_scope_cache) { +#if !defined(_WIN32) + setenv("NVIDIA_TF32_OVERRIDE", "0", 1); +#endif auto config(SetConfig()); std::vector input, output; diff --git a/paddle/fluid/inference/tests/api/analyzer_ernie_tester.cc b/paddle/fluid/inference/tests/api/analyzer_ernie_tester.cc index 529bc0a819..1efbe7cecd 100644 --- a/paddle/fluid/inference/tests/api/analyzer_ernie_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_ernie_tester.cc @@ -39,18 +39,31 @@ void profile(bool use_mkldnn = false, bool use_gpu = false) { FLAGS_num_threads); } -TEST(Analyzer_ernie, profile) { profile(); } +TEST(Analyzer_ernie, profile) { +#if !defined(_WIN32) + setenv("NVIDIA_TF32_OVERRIDE", "0", 1); +#endif + profile(); +} #ifdef PADDLE_WITH_MKLDNN TEST(Analyzer_ernie, profile_mkldnn) { profile(true, false); } #endif // Check the model by gpu #if defined(PADDLE_WITH_CUDA) || defined(PADDLE_WITH_HIP) -TEST(Analyzer_ernie, profile_gpu) { profile(false, true); } +TEST(Analyzer_ernie, profile_gpu) { +#if !defined(_WIN32) + setenv("NVIDIA_TF32_OVERRIDE", "0", 1); +#endif + profile(false, true); +} #endif // Check the fuse status TEST(Analyzer_Ernie, fuse_statis) { +#if !defined(_WIN32) + setenv("NVIDIA_TF32_OVERRIDE", "0", 1); +#endif AnalysisConfig cfg; SetConfig(&cfg); @@ -85,13 +98,21 @@ void compare(bool use_mkldnn = false) { reinterpret_cast(&cfg), inputs); } -TEST(Analyzer_ernie, compare) { compare(); } +TEST(Analyzer_ernie, compare) { +#if !defined(_WIN32) + setenv("NVIDIA_TF32_OVERRIDE", "0", 1); +#endif + compare(); +} #ifdef PADDLE_WITH_MKLDNN TEST(Analyzer_ernie, compare_mkldnn) { compare(true /* use_mkldnn */); } #endif // Compare Deterministic result TEST(Analyzer_Ernie, compare_determine) { +#if !defined(_WIN32) + setenv("NVIDIA_TF32_OVERRIDE", "0", 1); +#endif AnalysisConfig cfg; SetConfig(&cfg); auto pass_builder = cfg.pass_builder(); @@ -104,6 +125,9 @@ TEST(Analyzer_Ernie, compare_determine) { // Compare results TEST(Analyzer_Ernie, compare_results) { +#if !defined(_WIN32) + setenv("NVIDIA_TF32_OVERRIDE", "0", 1); +#endif AnalysisConfig cfg; SetConfig(&cfg); auto pass_builder = cfg.pass_builder(); @@ -150,6 +174,9 @@ TEST(Analyzer_Ernie_ipu, ipu_compare_determine) { // IPU: Compare results TEST(Analyzer_Ernie_ipu, ipu_compare_results) { +#if !defined(_WIN32) + setenv("NVIDIA_TF32_OVERRIDE", "0", 1); +#endif AnalysisConfig cfg; SetIpuConfig(&cfg); -- GitLab