提交 692a04ec 编写于 作者: Z Zhaolong Xing 提交者: kolinwei

CHERRY_PICK: 20955, 20966 (#20968)

Paddle-trt inference: filter conv, depthwise_conv, pooling when padding size > 4
fix C++ multicard  inference bug.
test=develop
上级 33d7aae1
......@@ -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<int> paddings =
boost::get<std::vector<int>>(desc.GetAttr("paddings"));
if (paddings.size() > 2) return false;
}
if ((*teller)(op_type, desc)) return true;
}
return false;
......
......@@ -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<PaddlePredictor> 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);
}
......
......@@ -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<int> paddings =
boost::get<std::vector<int>>(desc.GetAttr("paddings"));
if (paddings.size() > 2) return false;
}
if ((*teller)(op_type, desc)) return true;
}
return false;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册