From 9a04540c312c0fb5fc804d01481f979e033fd045 Mon Sep 17 00:00:00 2001 From: zhoutianzi666 <39978853+zhoutianzi666@users.noreply.github.com> Date: Wed, 10 Aug 2022 17:56:27 +0800 Subject: [PATCH] [Paddle-TRT] fix conv2d/int64 (#45023) * fix_conv2d_2_3 * commit * fix_conv2d_2_3 * fix_conv2d_2_3 * fix_conv2d_2_3 --- paddle/fluid/inference/tensorrt/op_teller.cc | 61 ++++++++++++++++++++ 1 file changed, 61 insertions(+) diff --git a/paddle/fluid/inference/tensorrt/op_teller.cc b/paddle/fluid/inference/tensorrt/op_teller.cc index 6f413dd0042..b23611c144f 100644 --- a/paddle/fluid/inference/tensorrt/op_teller.cc +++ b/paddle/fluid/inference/tensorrt/op_teller.cc @@ -354,6 +354,22 @@ bool OpTeller::Tell(const framework::ir::Node* node, } } #endif + // In fact, this should include all conv, not only conv2d + if (op_type == "conv2d") { + auto* block = desc.Block(); + if (block == nullptr) { + VLOG(3) << "The block desc is nullptr, we can't continue to analyze. " + "Developers need to check whether block_desc is passed in " + "the pass."; + return false; + } + auto* filter_var_desc = block->FindVar(desc.Input("Filter")[0]); + if (!filter_var_desc->Persistable()) { + VLOG(3) << "Trt not support filter is a intermediate tensor in " + "conv2d op."; + return false; + } + } } if (op_type == "deformable_conv") { @@ -912,6 +928,19 @@ bool OpTeller::Tell(const framework::ir::Node* node, return false; } } + auto* block = desc.Block(); + if (block == nullptr) { + VLOG(3) << "The block desc is nullptr, we can't continue to analyze. " + "Developers need to check whether block_desc is passed in " + "the pass."; + return false; + } + auto* x_var_desc = block->FindVar(desc.Input("X")[0]); + auto dtype = x_var_desc->GetDataType(); + // At present, forbid int64_t into trt. + if (dtype == 3) { + return false; + } } if (op_type == "unsqueeze2") { @@ -931,6 +960,19 @@ bool OpTeller::Tell(const framework::ir::Node* node, return false; } } + auto* block = desc.Block(); + if (block == nullptr) { + VLOG(3) << "The block desc is nullptr, we can't continue to analyze. " + "Developers need to check whether block_desc is passed in " + "the pass."; + return false; + } + auto* x_var_desc = block->FindVar(desc.Input("X")[0]); + auto dtype = x_var_desc->GetDataType(); + // At present, forbid int64_t into trt. + if (dtype == 3) { + return false; + } } if (op_type == "batch_norm") { @@ -1073,6 +1115,11 @@ bool OpTeller::Tell(const framework::ir::Node* node, auto x_var_name = desc.Input("X")[0]; auto* x_var_desc = block->FindVar(x_var_name); const auto x_shape = x_var_desc->GetShape(); + auto dtype = x_var_desc->GetDataType(); + // At present, only support float32 or float16 into trt. + if (!(dtype == 5 || dtype == 4)) { + return false; + } if (!with_dynamic_shape && x_shape.size() == 1) { VLOG(3) << "Scale op does not support 1-dimensional input in tensorrt"; return false; @@ -1163,6 +1210,20 @@ bool OpTeller::Tell(const framework::ir::Node* node, return false; } } + + auto* block = desc.Block(); + if (block == nullptr) { + VLOG(3) << "The block desc is nullptr, we can't continue to analyze. " + "Developers need to check whether block_desc is passed in " + "the pass."; + return false; + } + auto* x_var_desc = block->FindVar(desc.Input("Input")[0]); + auto dtype = x_var_desc->GetDataType(); + // At present, forbid int64_t into trt. + if (dtype == 3) { + return false; + } } if (op_type == "elementwise_add" || op_type == "elementwise_mul" || -- GitLab