diff --git a/paddle/fluid/inference/tensorrt/op_teller.cc b/paddle/fluid/inference/tensorrt/op_teller.cc index bae0c89c0cfb9cebfa10e6f66eeaea3b1d50a14c..414beef69ffbac08a71313b3751478887242349f 100644 --- a/paddle/fluid/inference/tensorrt/op_teller.cc +++ b/paddle/fluid/inference/tensorrt/op_teller.cc @@ -1155,6 +1155,14 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8, return false; } } + +#if IS_TRT_VERSION_LT(7000) + if (!with_dynamic_shape) { + // TODO(inference): fix trt6 static plugin error. + VLOG(3) << "prelu static plugin in trt6 has bug."; + return false; + } +#endif } if (op_type == "roi_align") { diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_activation.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_activation.py index 9dc89bb9836d07e9643b7e32480385ebe2233b3e..a87cab3430cd3043fe3af6c8090e72a9c45a7645 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_activation.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_activation.py @@ -14,6 +14,7 @@ from trt_layer_auto_scan_test import TrtLayerAutoScanTest, SkipReasons from program_config import TensorConfig, ProgramConfig +import unittest import numpy as np import paddle.inference as paddle_infer from functools import partial diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_affine_channel.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_affine_channel.py index 1e6c94f145497c4666b7f387f3242e9f9d5a37dc..33eb90b9f912306571636db12cc3e57900af1374 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_affine_channel.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_affine_channel.py @@ -14,6 +14,7 @@ from trt_layer_auto_scan_test import TrtLayerAutoScanTest, SkipReasons from program_config import TensorConfig, ProgramConfig +import unittest import numpy as np import paddle.inference as paddle_infer from functools import partial diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_elementwise.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_elementwise.py index 2d18738b614cb525f1b82ff9e58e7a13de024abd..60c203f4cb33882995e1c752f008d0b14028c422 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_elementwise.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_elementwise.py @@ -14,6 +14,7 @@ from trt_layer_auto_scan_test import TrtLayerAutoScanTest, SkipReasons from program_config import TensorConfig, ProgramConfig +import unittest import numpy as np import paddle.inference as paddle_infer from functools import partial diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_flatten.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_flatten.py index 4b461c75f0b28d04fb2ed149fe08304a3f1894e7..7b0089ab9ab7f7c3f11250a3217e113755f3cb2e 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_flatten.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_flatten.py @@ -14,6 +14,7 @@ from trt_layer_auto_scan_test import TrtLayerAutoScanTest, SkipReasons from program_config import TensorConfig, ProgramConfig +import unittest import numpy as np import paddle.inference as paddle_infer from functools import partial @@ -73,10 +74,20 @@ class TrtConvertFlattenTest_dim_2(TrtLayerAutoScanTest): self.dynamic_shape.opt_input_shape = {} def generate_trt_nodes_num(attrs, dynamic_shape): - if attrs[0]['axis'] == 1: - return 1, 2 + ver = paddle_infer.get_trt_compile_version() + if ver[0] * 1000 + ver[1] * 100 + ver[0] * 10 >= 7130: + if attrs[0]['axis'] == 1: + return 1, 2 + else: + return 0, 3 else: - return 0, 3 + if dynamic_shape: + return 0, 3 + + if attrs[0]['axis'] == 1: + return 1, 2 + else: + return 0, 3 attrs = [ program_config.ops[i].attrs @@ -157,10 +168,20 @@ class TrtConvertFlattenTest_dim_3(TrtLayerAutoScanTest): self.dynamic_shape.opt_input_shape = {} def generate_trt_nodes_num(attrs, dynamic_shape): - if attrs[0]['axis'] == 1: - return 1, 2 + ver = paddle_infer.get_trt_compile_version() + if ver[0] * 1000 + ver[1] * 100 + ver[0] * 10 >= 7130: + if attrs[0]['axis'] == 1: + return 1, 2 + else: + return 0, 3 else: - return 0, 3 + if dynamic_shape: + return 0, 3 + + if attrs[0]['axis'] == 1: + return 1, 2 + else: + return 0, 3 attrs = [ program_config.ops[i].attrs @@ -241,10 +262,20 @@ class TrtConvertFlattenTest_dim_4(TrtLayerAutoScanTest): self.dynamic_shape.opt_input_shape = {} def generate_trt_nodes_num(attrs, dynamic_shape): - if attrs[0]['axis'] == 1: - return 1, 2 + ver = paddle_infer.get_trt_compile_version() + if ver[0] * 1000 + ver[1] * 100 + ver[0] * 10 >= 7130: + if attrs[0]['axis'] == 1: + return 1, 2 + else: + return 0, 3 else: - return 0, 3 + if dynamic_shape: + return 0, 3 + + if attrs[0]['axis'] == 1: + return 1, 2 + else: + return 0, 3 attrs = [ program_config.ops[i].attrs @@ -325,10 +356,20 @@ class TrtConvertFlattenTest_dim_5(TrtLayerAutoScanTest): self.dynamic_shape.opt_input_shape = {} def generate_trt_nodes_num(attrs, dynamic_shape): - if attrs[0]['axis'] == 1: - return 1, 2 + ver = paddle_infer.get_trt_compile_version() + if ver[0] * 1000 + ver[1] * 100 + ver[0] * 10 >= 7130: + if attrs[0]['axis'] == 1: + return 1, 2 + else: + return 0, 3 else: - return 0, 3 + if dynamic_shape: + return 0, 3 + + if attrs[0]['axis'] == 1: + return 1, 2 + else: + return 0, 3 attrs = [ program_config.ops[i].attrs diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_gather.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_gather.py index 9a3c9aff61b987184f2cce4246c0fce417fe5753..37d23cb18d843ad11f3c893b44c4f47cb03f3aa0 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_gather.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_gather.py @@ -19,6 +19,7 @@ import paddle.inference as paddle_infer from functools import partial from typing import Optional, List, Callable, Dict, Any, Set import logging +import unittest class TrtConvertGatherTest(TrtLayerAutoScanTest): diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_gather_nd.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_gather_nd.py index a109abdc298a659c37a051a4118be87a334f2a97..0c7eae5f85f9557f6db58af8c4e6a677894ede05 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_gather_nd.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_gather_nd.py @@ -18,6 +18,7 @@ import numpy as np import paddle.inference as paddle_infer from functools import partial from typing import Optional, List, Callable, Dict, Any, Set +import unittest class TrtConvertGatherNdTest_dim_4_1(TrtLayerAutoScanTest): diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_gelu.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_gelu.py index f9c3d09ef446f56c0a93595b8ecb1acd5ddae6df..2f75e4e723e281b31f2f75bcc7cee89389036142 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_gelu.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_gelu.py @@ -18,6 +18,7 @@ import numpy as np import paddle.inference as paddle_infer from functools import partial from typing import Optional, List, Callable, Dict, Any, Set +import unittest class TrtConvertGeluTest(TrtLayerAutoScanTest): diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_group_norm.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_group_norm.py index 0224f20ec747e1791300d906eb432c8546a776a7..fb62be400ac7ca04a920274b023fda3abca10938 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_group_norm.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_group_norm.py @@ -18,6 +18,7 @@ import numpy as np import paddle.inference as paddle_infer from functools import partial from typing import Optional, List, Callable, Dict, Any, Set +import unittest class TrtConvertGroupNormTest(TrtLayerAutoScanTest): diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_prelu.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_prelu.py index 4122e2623cb5a7c90bac8fac0914c38e0d5d475e..fbb78fceb3e84a11fa35d05ce3a86150c24cdb78 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_prelu.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_prelu.py @@ -18,6 +18,7 @@ import numpy as np import paddle.inference as paddle_infer from functools import partial from typing import Optional, List, Callable, Dict, Any, Set +import unittest class TrtConvertPreluTest(TrtLayerAutoScanTest): @@ -186,6 +187,19 @@ class TrtConvertPreluTest(TrtLayerAutoScanTest): "Need to repair the case: the output of GPU and tensorrt has diff when the input dimension is 2 in static shape mode." ) + ver = paddle_infer.get_trt_compile_version() + if ver[0] * 1000 + ver[1] * 100 + ver[0] * 10 < 7000: + + def teller(program_config, predictor_config): + if not predictor_config.tensorrt_dynamic_shape_enabled(): + return True + return False + + self.add_skip_case( + teller, SkipReasons.TRT_NOT_IMPLEMENTED, + "Need to repair the case: the output of GPU and tensorrt has diff in trt6, the prelu static plugin has bug." + ) + def test(self): self.add_skip_trt_case() self.run_test() diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_reshape.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_reshape.py index cf7ab11c35de741284ef1c5764456c7b8aff5be4..4355b83557fc6d7d8eb20b5c9131fc0e50c23397 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_reshape.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_reshape.py @@ -18,6 +18,7 @@ import numpy as np import paddle.inference as paddle_infer from functools import partial from typing import Optional, List, Callable, Dict, Any, Set +import unittest class TrtConvertReshapeTest(TrtLayerAutoScanTest): diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_scale.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_scale.py index 8a44617dc8dc3c27c915291bc4e973876eeaf534..51bcee080376ea55a11d911978d5c36013ca4693 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_scale.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_scale.py @@ -18,6 +18,7 @@ import numpy as np import paddle.inference as paddle_infer from functools import partial from typing import Optional, List, Callable, Dict, Any, Set +import unittest class TrtConvertScaleTest(TrtLayerAutoScanTest): diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_shuffle_channel.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_shuffle_channel.py index 264ba31ad2716a2d99751de4b21f403e4652f112..c6a81472360447f00e6861fa371f1e5814bd49e4 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_shuffle_channel.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_shuffle_channel.py @@ -18,6 +18,7 @@ import numpy as np import paddle.inference as paddle_infer from functools import partial from typing import Optional, List, Callable, Dict, Any, Set +import unittest class TrtConvertShuffleChannelTest(TrtLayerAutoScanTest): diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_swish.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_swish.py index e162988bbb1b3990707dc588b36c0d5197f63192..5eb4e8505ff228801de5b81f0141d3bfc7d5465b 100755 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_swish.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_swish.py @@ -18,6 +18,7 @@ import numpy as np import paddle.inference as paddle_infer from functools import partial from typing import Optional, List, Callable, Dict, Any, Set +import unittest class TrtConvertSwishTest(TrtLayerAutoScanTest): diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_transpose.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_transpose.py index ad325bb0ab3b0cb90379b3b80f25a0e0bb9e1cb1..31b4d027f1780b604ed39cdb0a1ae56e0daee74c 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_transpose.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_transpose.py @@ -18,6 +18,7 @@ import numpy as np import paddle.inference as paddle_infer from functools import partial from typing import Optional, List, Callable, Dict, Any, Set +import unittest class TrtConvertTransposeTest(TrtLayerAutoScanTest):