Skip to content

Commit 692a04e

Browse files
NHZlXkolinwei
authored andcommitted
CHERRY_PICK: 20955, 20966 (#20968)
Paddle-trt inference: filter conv, depthwise_conv, pooling when padding size > 4 fix C++ multicard inference bug. test=develop
1 parent 33d7aae commit 692a04e

File tree

3 files changed

+13
-3
lines changed

3 files changed

+13
-3
lines changed

paddle/fluid/inference/anakin/op_teller.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,12 @@ struct SimpleOpTypeSetTeller : public Teller {
6262

6363
bool OpTeller::Tell(const std::string& op_type, const framework::OpDesc& desc) {
6464
for (auto& teller : tellers_) {
65+
if (op_type == "pool2d" || op_type == "conv2d" ||
66+
op_type == "depthwise_conv2d" || op_type == "conv2d_transpose") {
67+
std::vector<int> paddings =
68+
boost::get<std::vector<int>>(desc.GetAttr("paddings"));
69+
if (paddings.size() > 2) return false;
70+
}
6571
if ((*teller)(op_type, desc)) return true;
6672
}
6773
return false;

paddle/fluid/inference/api/analysis_predictor.cc

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ bool AnalysisPredictor::PrepareScope(
123123
status_is_cloned_ = true;
124124
} else {
125125
if (config_.use_gpu_) {
126-
paddle::framework::InitDevices(false, {config_.device_id_});
126+
paddle::framework::InitDevices(false);
127127
} else {
128128
paddle::framework::InitDevices(false, {});
129129
}
@@ -500,8 +500,6 @@ std::unique_ptr<PaddlePredictor> CreatePaddlePredictor<
500500
std::string flag = "--fraction_of_gpu_memory_to_use=" +
501501
std::to_string(fraction_of_gpu_memory);
502502
flags.push_back(flag);
503-
flags.push_back("--selected_gpus=" +
504-
std::to_string(config.gpu_device_id()));
505503
VLOG(3) << "set flag: " << flag;
506504
framework::InitGflags(flags);
507505
}

paddle/fluid/inference/tensorrt/op_teller.cc

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,12 @@ struct SimpleOpTypeSetTeller : public Teller {
5757

5858
bool OpTeller::Tell(const std::string& op_type, const framework::OpDesc& desc) {
5959
for (auto& teller : tellers_) {
60+
if (op_type == "pool2d" || op_type == "conv2d" ||
61+
op_type == "depthwise_conv2d" || op_type == "conv2d_transpose") {
62+
std::vector<int> paddings =
63+
boost::get<std::vector<int>>(desc.GetAttr("paddings"));
64+
if (paddings.size() > 2) return false;
65+
}
6066
if ((*teller)(op_type, desc)) return true;
6167
}
6268
return false;

0 commit comments

Comments
 (0)