From bccb0ba49ad84de2b52e293cdc1da8359ead6107 Mon Sep 17 00:00:00 2001 From: Sylwester Fraczek Date: Fri, 24 May 2019 06:28:27 +0200 Subject: [PATCH] fix quantize_squash_pass segfault when no tensor linked to Bias (#17292) * fix quantize_squash_pass segfault when there is no tensor linked do Bias input test=develop * add googlenet test test=develop * fix concat CreateKey not using input format test=develop --- .../fluid/framework/ir/mkldnn/cpu_quantize_squash_pass.cc | 3 +++ paddle/fluid/inference/tests/api/CMakeLists.txt | 7 +++++++ paddle/fluid/operators/mkldnn/concat_mkldnn_op.cc | 2 ++ 3 files changed, 12 insertions(+) diff --git a/paddle/fluid/framework/ir/mkldnn/cpu_quantize_squash_pass.cc b/paddle/fluid/framework/ir/mkldnn/cpu_quantize_squash_pass.cc index debbbd6440b..de2e2d744c3 100644 --- a/paddle/fluid/framework/ir/mkldnn/cpu_quantize_squash_pass.cc +++ b/paddle/fluid/framework/ir/mkldnn/cpu_quantize_squash_pass.cc @@ -81,6 +81,9 @@ void CPUQuantizeSquashPass::Squash( auto quant_out_var_name = quant_out->Name(); auto next_op_inputs = next_op_desc->InputNames(); for (const auto& name : next_op_inputs) { + if (next_op_desc->Inputs().count(name) == 0 || + next_op_desc->Input(name).size() == 0) + continue; auto var_name = next_op_desc->Input(name)[0]; if (var_name.compare(quant_out_var_name) == 0) { next_op_desc->SetInput( diff --git a/paddle/fluid/inference/tests/api/CMakeLists.txt b/paddle/fluid/inference/tests/api/CMakeLists.txt index c19d293f094..367a37eecab 100644 --- a/paddle/fluid/inference/tests/api/CMakeLists.txt +++ b/paddle/fluid/inference/tests/api/CMakeLists.txt @@ -194,6 +194,13 @@ if(WITH_MKLDNN) inference_download_and_uncompress(${INT8_VGG19_MODEL_DIR} "${INFERENCE_URL}/int8" "VGG19_int8_model.tar.gz" ) endif() inference_analysis_api_int8_test(test_analyzer_int8_vgg19 ${INT8_VGG19_MODEL_DIR} ${INT8_DATA_DIR} analyzer_int8_image_classification_tester.cc) + + #googlenet int8 + set(INT8_GOOGLENET_MODEL_DIR "${INT8_DATA_DIR}/googlenet") + if (NOT EXISTS ${INT8_GOOGLENET_MODEL_DIR}) + inference_download_and_uncompress(${INT8_GOOGLENET_MODEL_DIR} "${INFERENCE_URL}/int8" "GoogleNet_int8_model.tar.gz" ) + endif() + inference_analysis_api_int8_test(test_analyzer_int8_googlenet ${INT8_GOOGLENET_MODEL_DIR} ${INT8_DATA_DIR} analyzer_int8_image_classification_tester.cc SERIAL) endif() # bert, max_len=20, embedding_dim=128 diff --git a/paddle/fluid/operators/mkldnn/concat_mkldnn_op.cc b/paddle/fluid/operators/mkldnn/concat_mkldnn_op.cc index 50fe2e6e4c5..a855ba8475a 100644 --- a/paddle/fluid/operators/mkldnn/concat_mkldnn_op.cc +++ b/paddle/fluid/operators/mkldnn/concat_mkldnn_op.cc @@ -79,6 +79,8 @@ std::string CreateKey(const paddle::framework::ExecutionContext& ctx, platform::MKLDNNHandler::AppendKey(&key, std::to_string(concat_axis)); platform::MKLDNNHandler::AppendKey(&key, ctx.op().Output("Out")); platform::MKLDNNHandler::AppendKey(&key, std::to_string(dt)); + platform::MKLDNNHandler::AppendKey(&key, + std::to_string(multi_input[0]->format())); return key; } -- GitLab