Skip to content

Commit 01cfb0c

Browse files
authored
clean some IS_TRT_VERSION_GE(7000) (PaddlePaddle#75863)
1 parent ceeaeaa commit 01cfb0c

File tree

7 files changed

+0
-98
lines changed

7 files changed

+0
-98
lines changed

paddle/fluid/inference/tensorrt/convert/cumsum_op.cc

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ class CumsumOpConverter : public OpConverter {
2424
void operator()(const framework::proto::OpDesc& op,
2525
const framework::Scope& scope,
2626
bool test_mode) override {
27-
#if IS_TRT_VERSION_GE(7220)
2827
VLOG(3) << "convert a cumsum op to tensorrt layer";
2928
framework::OpDesc op_desc(op, nullptr);
3029
std::string input_x_name = op_desc.Input("X").front();
@@ -161,9 +160,6 @@ class CumsumOpConverter : public OpConverter {
161160
loopOut->setInput(1, *tripLimit);
162161
ReplenishLayerAndOutput(loopOut, "cumsum", {output_name}, test_mode);
163162
}
164-
#else
165-
VLOG(3) << "Cumsum is not supported when TensorRT < 7.2.2";
166-
#endif
167163
}
168164
};
169165

paddle/fluid/inference/tensorrt/engine.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,11 +43,9 @@ void TensorRTEngine::Weight::SetDataType(phi::DataType type) {
4343
case phi::DataType::INT8:
4444
nv_type = nvinfer1::DataType::kINT8;
4545
break;
46-
#if IS_TRT_VERSION_GE(7000)
4746
case phi::DataType::BOOL:
4847
nv_type = nvinfer1::DataType::kBOOL;
4948
break;
50-
#endif
5149
default:
5250
common::errors::InvalidArgument(
5351
"Paddle-TRT loads weights failed, found not supported data type %s.",

paddle/fluid/inference/tensorrt/helper.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -218,11 +218,9 @@ static inline nvinfer1::DataType PhiType2NvType(phi::DataType type) {
218218
case phi::DataType::INT8:
219219
nv_type = nvinfer1::DataType::kINT8;
220220
break;
221-
#if IS_TRT_VERSION_GE(7000)
222221
case phi::DataType::BOOL:
223222
nv_type = nvinfer1::DataType::kBOOL;
224223
break;
225-
#endif
226224
default:
227225
common::errors::InvalidArgument(
228226
"phi::DataType not supported data type %s.", type);

paddle/fluid/inference/tensorrt/op_teller.cc

Lines changed: 0 additions & 84 deletions
Original file line numberDiff line numberDiff line change
@@ -70,15 +70,12 @@ bool IsDynamicShapeOp(const framework::OpDesc& desc) {
7070
// Just tell by the op_types.
7171
struct SimpleOpTypeSetTeller : public Teller {
7272
SimpleOpTypeSetTeller() { // NOLINT
73-
#if IS_TRT_VERSION_GE(7130)
7473
// use TensorRT plugin
7574
teller_set.insert("group_norm");
7675
teller_set.insert("multiclass_nms3");
7776
teller_set.insert("multiclass_nms");
7877
int8_teller_set.insert("multiclass_nms3");
7978
int8_teller_set.insert("multiclass_nms");
80-
#endif
81-
#if IS_TRT_VERSION_GE(7000)
8279
teller_set.insert("tile");
8380
int8_teller_set.insert("tile");
8481
teller_set.insert("flatten_contiguous_range");
@@ -87,17 +84,14 @@ struct SimpleOpTypeSetTeller : public Teller {
8784
int8_teller_set.insert("rnn");
8885
teller_set.insert("fill_constant_batch_size_like");
8986
int8_teller_set.insert("fill_constant_batch_size_like");
90-
#endif
9187
teller_set.insert("reshape");
9288
teller_set.insert("reshape2");
9389
int8_teller_set.insert("reshape");
9490
int8_teller_set.insert("reshape2");
95-
#if IS_TRT_VERSION_GE(8000)
9691
teller_set.insert("sparse_fc");
9792
int8_teller_set.insert("sparse_fc");
9893
teller_set.insert("sparse_multihead_matmul");
9994
int8_teller_set.insert("sparse_multihead_matmul");
100-
#endif
10195
#if IS_TRT_VERSION_GE(8522)
10296
teller_set.insert("flash_multihead_matmul");
10397
int8_teller_set.insert("flash_multihead_matmul");
@@ -193,12 +187,6 @@ struct SimpleOpTypeSetTeller : public Teller {
193187
"the pass.";
194188
return false;
195189
}
196-
#if !IS_TRT_VERSION_GE(7000)
197-
if (op_type == "erf") {
198-
VLOG(3) << op_type << " op does not support tensorrt.";
199-
return false;
200-
}
201-
#endif
202190
auto x_var_name = desc.Input("X")[0];
203191
auto* x_var_desc = block->FindVarRecursive(x_var_name);
204192
auto x_dtype = x_var_desc->GetDataType();
@@ -345,26 +333,6 @@ struct SimpleOpTypeSetTeller : public Teller {
345333
return false;
346334
}
347335

348-
// strides > 1 and 'SAME' is only supported by trt7.0 above
349-
#if !IS_TRT_VERSION_GE(7000)
350-
if (op_type == "conv2d" || op_type == "fused_conv2d_add_act" ||
351-
op_type == "depthwise_conv2d") {
352-
if (desc.HasAttr("padding_algorithm") && with_dynamic_shape) {
353-
auto padding_algorithm =
354-
PADDLE_GET_CONST(std::string, desc.GetAttr("padding_algorithm"));
355-
if (padding_algorithm == "SAME" && desc.HasAttr("strides")) {
356-
const std::vector<int> strides =
357-
PADDLE_GET_CONST(std::vector<int>, desc.GetAttr("strides"));
358-
// there is no issue if strides.size() less than 2
359-
if (strides.size() > 1) {
360-
for (size_t i = 0; i < strides.size(); i++) {
361-
if (strides[i] > 1) return false;
362-
}
363-
}
364-
}
365-
}
366-
}
367-
#endif
368336
auto* block = desc.Block();
369337
if (block) {
370338
auto* filter_var_desc =
@@ -569,10 +537,6 @@ struct SimpleOpTypeSetTeller : public Teller {
569537
if (!desc.HasAttr("axis")) {
570538
return false;
571539
} else {
572-
#if IS_TRT_VERSION_GE(7130)
573-
#else
574-
if (with_dynamic_shape) return false;
575-
#endif
576540
int axis = PADDLE_GET_CONST(int, desc.GetAttr("axis"));
577541
if (axis != 1) return false;
578542
}
@@ -635,14 +599,6 @@ struct SimpleOpTypeSetTeller : public Teller {
635599
"the pass.";
636600
return false;
637601
}
638-
#if !IS_TRT_VERSION_GE(7000)
639-
auto* x_var_desc = block->FindVarRecursive(desc.Input("X")[0]);
640-
const auto x_shape = x_var_desc->GetShape();
641-
if (x_shape.size() == 1) {
642-
VLOG(3) << "Gather does not support 1-dimensional input in tensorrt";
643-
return false;
644-
}
645-
#endif
646602
}
647603
}
648604

@@ -1315,21 +1271,12 @@ struct SimpleOpTypeSetTeller : public Teller {
13151271
}
13161272

13171273
if (op_type == "roll") {
1318-
#if !IS_TRT_VERSION_GE(7000)
1319-
VLOG(3) << "roll converter does not support trt versions below 7.0";
1320-
return false;
1321-
#endif
13221274
if (!with_dynamic_shape) {
13231275
return false;
13241276
}
13251277
}
13261278

13271279
if (op_type == "strided_slice") {
1328-
#if !IS_TRT_VERSION_GE(7000)
1329-
VLOG(3)
1330-
<< "strided_slice converter does not support trt versions below 7.0";
1331-
return false;
1332-
#endif
13331280
if (!desc.HasAttr("axes") || !desc.HasAttr("starts") ||
13341281
!desc.HasAttr("ends") || !desc.HasAttr("strides")) {
13351282
VLOG(3)
@@ -2398,7 +2345,6 @@ struct SimpleOpTypeSetTeller : public Teller {
23982345
return false;
23992346
}
24002347
} else {
2401-
#if IS_TRT_VERSION_GE(7000)
24022348
if (dtype != framework::proto::VarType::INT32 &&
24032349
dtype != framework::proto::VarType::INT64 &&
24042350
dtype != framework::proto::VarType::FP32 &&
@@ -2408,18 +2354,8 @@ struct SimpleOpTypeSetTeller : public Teller {
24082354
"float64";
24092355
return false;
24102356
}
2411-
#else
2412-
if (dtype != framework::proto::VarType::FP32 &&
2413-
dtype != framework::proto::VarType::FP64) {
2414-
VLOG(3) << "reduce op input data type must be float32 or float64 "
2415-
"using TensorRT "
2416-
"< 7.0";
2417-
return false;
2418-
}
2419-
#endif
24202357
}
24212358
}
2422-
#if IS_TRT_VERSION_GE(7000)
24232359
if (op_type == "tile") {
24242360
// Paddle-TRT does not support the input tensors.
24252361
auto tile_inputs = desc.Inputs();
@@ -2442,7 +2378,6 @@ struct SimpleOpTypeSetTeller : public Teller {
24422378
}
24432379
}
24442380
}
2445-
#endif
24462381

24472382
// conv3d_transpose
24482383
if (op_type == "conv3d_transpose") {
@@ -2473,13 +2408,6 @@ struct SimpleOpTypeSetTeller : public Teller {
24732408
}
24742409
}
24752410

2476-
#if !IS_TRT_VERSION_GE(7000)
2477-
// looks like some issues with trt6.0
2478-
if (with_dynamic_shape) {
2479-
return false;
2480-
}
2481-
#endif
2482-
24832411
std::vector<int> paddings =
24842412
PADDLE_GET_CONST(std::vector<int>, desc.GetAttr("paddings"));
24852413

@@ -2522,10 +2450,6 @@ struct SimpleOpTypeSetTeller : public Teller {
25222450
}
25232451

25242452
if (op_type == "cast") {
2525-
// trt 6015 result in Windows ppyolo_mbv3 TRT fp32 diff
2526-
#if !IS_TRT_VERSION_GE(7000)
2527-
return false;
2528-
#endif
25292453
if (!(desc.HasAttr("in_dtype") && desc.HasAttr("out_dtype"))) {
25302454
VLOG(3) << "the " << op_type
25312455
<< " does not have attr (in_dtype or "
@@ -2821,10 +2745,6 @@ struct SimpleOpTypeSetTeller : public Teller {
28212745
}
28222746

28232747
if (op_type == "cumsum") {
2824-
#if !IS_TRT_VERSION_GE(7220)
2825-
VLOG(3) << "cumsum is not supported when TensorRT < 7.2.2";
2826-
return false;
2827-
#endif
28282748
if (!with_dynamic_shape) {
28292749
VLOG(3) << "the cumsum does not support "
28302750
"static shape yet";
@@ -3037,10 +2957,6 @@ struct SimpleOpTypeSetTeller : public Teller {
30372957
"static shape yet";
30382958
return false;
30392959
}
3040-
#if !IS_TRT_VERSION_GE(7220)
3041-
VLOG(3) << "flip is not supported when TensorRT below 7.2.2";
3042-
return false;
3043-
#endif
30442960
}
30452961

30462962
if (use_no_calib_int8) {

paddle/fluid/operators/tensorrt/tensorrt_engine_op.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,10 +96,8 @@ static phi::DataType TRT2FluidDataType(nvinfer1::DataType type) {
9696
return phi::DataType::FLOAT16;
9797
case nvinfer1::DataType::kINT8:
9898
return phi::DataType::INT8;
99-
#if IS_TRT_VERSION_GE(7000)
10099
case nvinfer1::DataType::kBOOL:
101100
return phi::DataType::BOOL;
102-
#endif
103101
default:
104102
PADDLE_THROW(common::errors::InvalidArgument(
105103
"unknown fluid datatype in Fluid op converter"));

paddle/fluid/platform/tensorrt/engine.cc

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,11 +42,9 @@ void TensorRTEngine::Weight::SetDataType(phi::DataType type) {
4242
case phi::DataType::INT8:
4343
nv_type = nvinfer1::DataType::kINT8;
4444
break;
45-
#if IS_TRT_VERSION_GE(7000)
4645
case phi::DataType::BOOL:
4746
nv_type = nvinfer1::DataType::kBOOL;
4847
break;
49-
#endif
5048
default:
5149
common::errors::InvalidArgument(
5250
"Paddle-TRT loads weights failed, found not supported data type %s.",

paddle/fluid/platform/tensorrt/helper.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -224,11 +224,9 @@ static inline nvinfer1::DataType PhiType2NvType(phi::DataType type) {
224224
case phi::DataType::INT8:
225225
nv_type = nvinfer1::DataType::kINT8;
226226
break;
227-
#if IS_TRT_VERSION_GE(7000)
228227
case phi::DataType::BOOL:
229228
nv_type = nvinfer1::DataType::kBOOL;
230229
break;
231-
#endif
232230
default:
233231
common::errors::InvalidArgument(
234232
"phi::DataType not supported data type %s.", type);

0 commit comments

Comments
 (0)