diff --git a/paddle/fluid/inference/tests/api/analyzer_bert_tester.cc b/paddle/fluid/inference/tests/api/analyzer_bert_tester.cc index 727d2576e57f7aa725d80c2e08b41789de9b05d0..db1f2953c742ffb60294edbfc1373a8e13af10ae 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 529bc0a8194baea360d1d10e3e5d776889c43d1b..1efbe7cecdde4a3dd81d7a752524cc181fc4703e 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);