From 8462e2b805918554ecb2de2a8c02af8ac39b3cdb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Gallus?= Date: Thu, 13 Jun 2019 06:02:32 +0200 Subject: [PATCH] Disable MKLDNN FC in Resnet50 test (#18030) --- cmake/generic.cmake | 2 +- paddle/fluid/inference/tests/api/CMakeLists.txt | 8 +++----- .../fluid/inference/tests/api/analyzer_resnet50_tester.cc | 8 ++++++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/cmake/generic.cmake b/cmake/generic.cmake index dfa90a3fe63..c5bedf376ba 100644 --- a/cmake/generic.cmake +++ b/cmake/generic.cmake @@ -385,7 +385,7 @@ function(cc_test TARGET_NAME) set_property(TEST ${TARGET_NAME} PROPERTY ENVIRONMENT FLAGS_cpu_deterministic=true) set_property(TEST ${TARGET_NAME} PROPERTY ENVIRONMENT FLAGS_init_allocated_mem=true) set_property(TEST ${TARGET_NAME} PROPERTY ENVIRONMENT FLAGS_limit_of_tmp_allocation=4294967296) # 4G - set_property(TEST ${TARGET_NAME} PROPERTY ENVIRONMENT FLAGS_cudnn_deterministic=true ${MKL_DEBUG_FLAG}) + set_property(TEST ${TARGET_NAME} PROPERTY ENVIRONMENT FLAGS_cudnn_deterministic=true) # No unit test should exceed 10 minutes. set_tests_properties(${TARGET_NAME} PROPERTIES TIMEOUT 600) endif() diff --git a/paddle/fluid/inference/tests/api/CMakeLists.txt b/paddle/fluid/inference/tests/api/CMakeLists.txt index 548ef382576..3422af32512 100644 --- a/paddle/fluid/inference/tests/api/CMakeLists.txt +++ b/paddle/fluid/inference/tests/api/CMakeLists.txt @@ -33,14 +33,12 @@ function(inference_analysis_api_int8_test target model_dir data_dir filename) --paddle_num_threads=${CPU_NUM_THREADS_ON_CI} --iterations=2) endfunction() -function(inference_analysis_api_test_with_fake_data target install_dir filename model_name mkl_debug) - if(mkl_debug) - set(MKL_DEBUG_FLAG MKL_DEBUG_CPU_TYPE=7) - endif() +function(inference_analysis_api_test_with_fake_data target install_dir filename model_name disable_fc) download_model(${install_dir} ${model_name}) inference_analysis_test(${target} SRCS ${filename} EXTRA_DEPS ${INFERENCE_EXTRA_DEPS} - ARGS --infer_model=${install_dir}/model) + ARGS --infer_model=${install_dir}/model + --disable_mkldnn_fc=${disable_fc}) endfunction() function(inference_analysis_api_test_with_refer_result target install_dir filename) diff --git a/paddle/fluid/inference/tests/api/analyzer_resnet50_tester.cc b/paddle/fluid/inference/tests/api/analyzer_resnet50_tester.cc index 602d59457c0..07934f96dc5 100644 --- a/paddle/fluid/inference/tests/api/analyzer_resnet50_tester.cc +++ b/paddle/fluid/inference/tests/api/analyzer_resnet50_tester.cc @@ -16,6 +16,8 @@ limitations under the License. */ #include #include "paddle/fluid/inference/tests/api/tester_helper.h" +DEFINE_bool(disable_mkldnn_fc, false, "Disable usage of MKL-DNN's FC op"); + namespace paddle { namespace inference { namespace analysis { @@ -48,7 +50,8 @@ void profile(bool use_mkldnn = false) { if (use_mkldnn) { cfg.EnableMKLDNN(); - cfg.pass_builder()->AppendPass("fc_mkldnn_pass"); + if (!FLAGS_disable_mkldnn_fc) + cfg.pass_builder()->AppendPass("fc_mkldnn_pass"); } std::vector> outputs; @@ -80,7 +83,8 @@ void compare(bool use_mkldnn = false) { SetConfig(&cfg); if (use_mkldnn) { cfg.EnableMKLDNN(); - cfg.pass_builder()->AppendPass("fc_mkldnn_pass"); + if (!FLAGS_disable_mkldnn_fc) + cfg.pass_builder()->AppendPass("fc_mkldnn_pass"); } std::vector> input_slots_all; -- GitLab