From 692a04ec3688a4b712be8838b15b98e615fa4536 Mon Sep 17 00:00:00 2001 From: Zhaolong Xing Date: Fri, 1 Nov 2019 22:24:55 +0800 Subject: [PATCH] CHERRY_PICK: 20955, 20966 (#20968) Paddle-trt inference: filter conv, depthwise_conv, pooling when padding size > 4 fix C++ multicard inference bug. test=develop --- paddle/fluid/inference/anakin/op_teller.cc | 6 ++++++ paddle/fluid/inference/api/analysis_predictor.cc | 4 +--- paddle/fluid/inference/tensorrt/op_teller.cc | 6 ++++++ 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/paddle/fluid/inference/anakin/op_teller.cc b/paddle/fluid/inference/anakin/op_teller.cc index 67b771226c..6b2dedafcf 100644 --- a/paddle/fluid/inference/anakin/op_teller.cc +++ b/paddle/fluid/inference/anakin/op_teller.cc @@ -62,6 +62,12 @@ struct SimpleOpTypeSetTeller : public Teller { bool OpTeller::Tell(const std::string& op_type, const framework::OpDesc& desc) { for (auto& teller : tellers_) { + if (op_type == "pool2d" || op_type == "conv2d" || + op_type == "depthwise_conv2d" || op_type == "conv2d_transpose") { + std::vector paddings = + boost::get>(desc.GetAttr("paddings")); + if (paddings.size() > 2) return false; + } if ((*teller)(op_type, desc)) return true; } return false; diff --git a/paddle/fluid/inference/api/analysis_predictor.cc b/paddle/fluid/inference/api/analysis_predictor.cc index e00ba4d840..7a62876972 100644 --- a/paddle/fluid/inference/api/analysis_predictor.cc +++ b/paddle/fluid/inference/api/analysis_predictor.cc @@ -123,7 +123,7 @@ bool AnalysisPredictor::PrepareScope( status_is_cloned_ = true; } else { if (config_.use_gpu_) { - paddle::framework::InitDevices(false, {config_.device_id_}); + paddle::framework::InitDevices(false); } else { paddle::framework::InitDevices(false, {}); } @@ -500,8 +500,6 @@ std::unique_ptr CreatePaddlePredictor< std::string flag = "--fraction_of_gpu_memory_to_use=" + std::to_string(fraction_of_gpu_memory); flags.push_back(flag); - flags.push_back("--selected_gpus=" + - std::to_string(config.gpu_device_id())); VLOG(3) << "set flag: " << flag; framework::InitGflags(flags); } diff --git a/paddle/fluid/inference/tensorrt/op_teller.cc b/paddle/fluid/inference/tensorrt/op_teller.cc index 292f5e1d4b..fce8daa1d6 100644 --- a/paddle/fluid/inference/tensorrt/op_teller.cc +++ b/paddle/fluid/inference/tensorrt/op_teller.cc @@ -57,6 +57,12 @@ struct SimpleOpTypeSetTeller : public Teller { bool OpTeller::Tell(const std::string& op_type, const framework::OpDesc& desc) { for (auto& teller : tellers_) { + if (op_type == "pool2d" || op_type == "conv2d" || + op_type == "depthwise_conv2d" || op_type == "conv2d_transpose") { + std::vector paddings = + boost::get>(desc.GetAttr("paddings")); + if (paddings.size() > 2) return false; + } if ((*teller)(op_type, desc)) return true; } return false; -- GitLab