Skip to content

Commit

Permalink
[inference][trt]Remove unused code from teller.cc (#53758)
Browse files Browse the repository at this point in the history
* remove unused code
  • Loading branch information
zhangjun committed May 16, 2023
1 parent 00c21ab commit 2a94b81
Showing 1 changed file with 1 addition and 103 deletions.
104 changes: 1 addition & 103 deletions paddle/fluid/inference/tensorrt/op_teller.cc
Original file line number Diff line number Diff line change
Expand Up @@ -416,12 +416,6 @@ struct SimpleOpTypeSetTeller : public Teller {
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();
if (!with_dynamic_shape && (x_shape.size() == 1 || x_shape.size() == 0)) {
VLOG(3) << op_type
<< " op does not support input's dim is 1 or 0 in tensorrt "
"with static shape.";
return false;
}

if (with_dynamic_shape && (x_shape.size() == 1 || x_shape.size() == 0)) {
int axis = desc.HasAttr("axis")
Expand Down Expand Up @@ -1198,11 +1192,6 @@ struct SimpleOpTypeSetTeller : public Teller {
dtype == framework::proto::VarType::FP16)) {
return false;
}
if (x_shape.size() == 1 || x_shape.size() == 0) {
VLOG(3) << "Scale op does not support 0 or 1-dimensional input in "
"tensorrt";
return false;
}
} else {
// At present, only support float32 or float16 or int32 or int64 into
// trt.
Expand Down Expand Up @@ -1527,13 +1516,7 @@ struct SimpleOpTypeSetTeller : public Teller {
return false;
}
auto* x_var_desc = block->FindVar(desc.Input("X")[0]);
const auto x_shape = x_var_desc->GetShape();
if (!with_dynamic_shape && (x_shape.size() == 1 || x_shape.size() == 0)) {
VLOG(3) << op_type
<< " op does not support input's dim is 1 or 0 in tensorrt "
"static shape mode.";
return false;
}

// the same as `elementwise_pow`.
if (x_var_desc->GetDataType() ==
paddle::framework::proto::VarType_Type::VarType_Type_INT32) {
Expand Down Expand Up @@ -1572,26 +1555,6 @@ struct SimpleOpTypeSetTeller : public Teller {
}
}

if (op_type == "sum") {
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_name = desc.Input("X")[0];
auto* x_var = block->FindVar(x_var_name);
const auto x_shape = x_var->GetShape();
if (!with_dynamic_shape && (x_shape.size() == 0 || x_shape.size() == 1)) {
VLOG(3) << op_type
<< " op does not support input's dim is 0 or 1 in tensorrt "
"with static shape.";
return false;
}
return true;
}

if (op_type == "shape" && !with_dynamic_shape) {
return false;
}
Expand Down Expand Up @@ -1657,24 +1620,6 @@ struct SimpleOpTypeSetTeller : public Teller {
if (PADDLE_GET_CONST(bool, desc.GetAttr("approximate"))) return false;
}
#endif

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_name = desc.Input("X")[0];
auto* x_var_desc = block->FindVar(x_var_name);
const auto x_shape = x_var_desc->GetShape();
if (!with_dynamic_shape && (x_shape.size() == 1 || x_shape.size() == 0)) {
VLOG(3) << op_type
<< "gelu op does not support input's dim is 1 or 0 in tensorrt "
"static shape mode.";
return false;
}
}

if (op_type == "layer_norm") {
Expand Down Expand Up @@ -1864,16 +1809,6 @@ struct SimpleOpTypeSetTeller : public Teller {
"static shape mode.";
return false;
}

auto x_var_name = desc.Input("X")[0];
auto* x_var = block->FindVar(x_var_name);
const auto x_shape = x_var->GetShape();
if (!with_dynamic_shape && (x_shape.size() == 1 || x_shape.size() == 0)) {
VLOG(3) << op_type
<< " op does not support input's dim is 1 or 0 in tensorrt "
"with static shape.";
return false;
}
}

if (op_type == "mish") {
Expand All @@ -1889,24 +1824,6 @@ struct SimpleOpTypeSetTeller : public Teller {
<< desc.Output("Out").size() << ".";
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_name = desc.Input("X")[0];
auto* x_var_desc = block->FindVar(x_var_name);
const auto x_shape = x_var_desc->GetShape();
if ((!with_dynamic_shape && x_shape.size() == 1) || x_shape.size() == 0) {
VLOG(3) << op_type
<< "mish op does not support input's dim is 1 in tensorrt "
"static shape mode or 0.";
return false;
}
}

if (op_type == "roi_align") {
Expand Down Expand Up @@ -2194,25 +2111,6 @@ struct SimpleOpTypeSetTeller : public Teller {
}
}

if (op_type == "square") {
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_name = desc.Input("X")[0];
auto* x_var = block->FindVar(x_var_name);
const auto x_shape = x_var->GetShape();
if (!with_dynamic_shape && x_shape.size() == 0) {
VLOG(3) << op_type
<< " op does not support input's dim is 0 in tensorrt "
"with static shape.";
return false;
}
}

if (op_type == "clip") {
// Paddle-TRT does not support the input tensors: Min and Max
auto clip_inputs = desc.Inputs();
Expand Down

0 comments on commit 2a94b81

Please sign in to comment.