未验证 提交 a540769b 编写于 作者: W Wilber 提交者: GitHub

[cherry-pick] enable trt test check and fix trt ut error (#36549) (#36655)

上级 0951bfd1
...@@ -1155,6 +1155,14 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8, ...@@ -1155,6 +1155,14 @@ bool OpTeller::Tell(const framework::ir::Node* node, bool use_no_calib_int8,
return false; 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") { if (op_type == "roi_align") {
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
from trt_layer_auto_scan_test import TrtLayerAutoScanTest, SkipReasons from trt_layer_auto_scan_test import TrtLayerAutoScanTest, SkipReasons
from program_config import TensorConfig, ProgramConfig from program_config import TensorConfig, ProgramConfig
import unittest
import numpy as np import numpy as np
import paddle.inference as paddle_infer import paddle.inference as paddle_infer
from functools import partial from functools import partial
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
from trt_layer_auto_scan_test import TrtLayerAutoScanTest, SkipReasons from trt_layer_auto_scan_test import TrtLayerAutoScanTest, SkipReasons
from program_config import TensorConfig, ProgramConfig from program_config import TensorConfig, ProgramConfig
import unittest
import numpy as np import numpy as np
import paddle.inference as paddle_infer import paddle.inference as paddle_infer
from functools import partial from functools import partial
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
from trt_layer_auto_scan_test import TrtLayerAutoScanTest, SkipReasons from trt_layer_auto_scan_test import TrtLayerAutoScanTest, SkipReasons
from program_config import TensorConfig, ProgramConfig from program_config import TensorConfig, ProgramConfig
import unittest
import numpy as np import numpy as np
import paddle.inference as paddle_infer import paddle.inference as paddle_infer
from functools import partial from functools import partial
......
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
from trt_layer_auto_scan_test import TrtLayerAutoScanTest, SkipReasons from trt_layer_auto_scan_test import TrtLayerAutoScanTest, SkipReasons
from program_config import TensorConfig, ProgramConfig from program_config import TensorConfig, ProgramConfig
import unittest
import numpy as np import numpy as np
import paddle.inference as paddle_infer import paddle.inference as paddle_infer
from functools import partial from functools import partial
...@@ -73,10 +74,20 @@ class TrtConvertFlattenTest_dim_2(TrtLayerAutoScanTest): ...@@ -73,10 +74,20 @@ class TrtConvertFlattenTest_dim_2(TrtLayerAutoScanTest):
self.dynamic_shape.opt_input_shape = {} self.dynamic_shape.opt_input_shape = {}
def generate_trt_nodes_num(attrs, dynamic_shape): def generate_trt_nodes_num(attrs, dynamic_shape):
if attrs[0]['axis'] == 1: ver = paddle_infer.get_trt_compile_version()
return 1, 2 if ver[0] * 1000 + ver[1] * 100 + ver[0] * 10 >= 7130:
if attrs[0]['axis'] == 1:
return 1, 2
else:
return 0, 3
else: else:
return 0, 3 if dynamic_shape:
return 0, 3
if attrs[0]['axis'] == 1:
return 1, 2
else:
return 0, 3
attrs = [ attrs = [
program_config.ops[i].attrs program_config.ops[i].attrs
...@@ -157,10 +168,20 @@ class TrtConvertFlattenTest_dim_3(TrtLayerAutoScanTest): ...@@ -157,10 +168,20 @@ class TrtConvertFlattenTest_dim_3(TrtLayerAutoScanTest):
self.dynamic_shape.opt_input_shape = {} self.dynamic_shape.opt_input_shape = {}
def generate_trt_nodes_num(attrs, dynamic_shape): def generate_trt_nodes_num(attrs, dynamic_shape):
if attrs[0]['axis'] == 1: ver = paddle_infer.get_trt_compile_version()
return 1, 2 if ver[0] * 1000 + ver[1] * 100 + ver[0] * 10 >= 7130:
if attrs[0]['axis'] == 1:
return 1, 2
else:
return 0, 3
else: else:
return 0, 3 if dynamic_shape:
return 0, 3
if attrs[0]['axis'] == 1:
return 1, 2
else:
return 0, 3
attrs = [ attrs = [
program_config.ops[i].attrs program_config.ops[i].attrs
...@@ -241,10 +262,20 @@ class TrtConvertFlattenTest_dim_4(TrtLayerAutoScanTest): ...@@ -241,10 +262,20 @@ class TrtConvertFlattenTest_dim_4(TrtLayerAutoScanTest):
self.dynamic_shape.opt_input_shape = {} self.dynamic_shape.opt_input_shape = {}
def generate_trt_nodes_num(attrs, dynamic_shape): def generate_trt_nodes_num(attrs, dynamic_shape):
if attrs[0]['axis'] == 1: ver = paddle_infer.get_trt_compile_version()
return 1, 2 if ver[0] * 1000 + ver[1] * 100 + ver[0] * 10 >= 7130:
if attrs[0]['axis'] == 1:
return 1, 2
else:
return 0, 3
else: else:
return 0, 3 if dynamic_shape:
return 0, 3
if attrs[0]['axis'] == 1:
return 1, 2
else:
return 0, 3
attrs = [ attrs = [
program_config.ops[i].attrs program_config.ops[i].attrs
...@@ -325,10 +356,20 @@ class TrtConvertFlattenTest_dim_5(TrtLayerAutoScanTest): ...@@ -325,10 +356,20 @@ class TrtConvertFlattenTest_dim_5(TrtLayerAutoScanTest):
self.dynamic_shape.opt_input_shape = {} self.dynamic_shape.opt_input_shape = {}
def generate_trt_nodes_num(attrs, dynamic_shape): def generate_trt_nodes_num(attrs, dynamic_shape):
if attrs[0]['axis'] == 1: ver = paddle_infer.get_trt_compile_version()
return 1, 2 if ver[0] * 1000 + ver[1] * 100 + ver[0] * 10 >= 7130:
if attrs[0]['axis'] == 1:
return 1, 2
else:
return 0, 3
else: else:
return 0, 3 if dynamic_shape:
return 0, 3
if attrs[0]['axis'] == 1:
return 1, 2
else:
return 0, 3
attrs = [ attrs = [
program_config.ops[i].attrs program_config.ops[i].attrs
......
...@@ -19,6 +19,7 @@ import paddle.inference as paddle_infer ...@@ -19,6 +19,7 @@ import paddle.inference as paddle_infer
from functools import partial from functools import partial
from typing import Optional, List, Callable, Dict, Any, Set from typing import Optional, List, Callable, Dict, Any, Set
import logging import logging
import unittest
class TrtConvertGatherTest(TrtLayerAutoScanTest): class TrtConvertGatherTest(TrtLayerAutoScanTest):
......
...@@ -18,6 +18,7 @@ import numpy as np ...@@ -18,6 +18,7 @@ import numpy as np
import paddle.inference as paddle_infer import paddle.inference as paddle_infer
from functools import partial from functools import partial
from typing import Optional, List, Callable, Dict, Any, Set from typing import Optional, List, Callable, Dict, Any, Set
import unittest
class TrtConvertGatherNdTest_dim_4_1(TrtLayerAutoScanTest): class TrtConvertGatherNdTest_dim_4_1(TrtLayerAutoScanTest):
......
...@@ -18,6 +18,7 @@ import numpy as np ...@@ -18,6 +18,7 @@ import numpy as np
import paddle.inference as paddle_infer import paddle.inference as paddle_infer
from functools import partial from functools import partial
from typing import Optional, List, Callable, Dict, Any, Set from typing import Optional, List, Callable, Dict, Any, Set
import unittest
class TrtConvertGeluTest(TrtLayerAutoScanTest): class TrtConvertGeluTest(TrtLayerAutoScanTest):
......
...@@ -18,6 +18,7 @@ import numpy as np ...@@ -18,6 +18,7 @@ import numpy as np
import paddle.inference as paddle_infer import paddle.inference as paddle_infer
from functools import partial from functools import partial
from typing import Optional, List, Callable, Dict, Any, Set from typing import Optional, List, Callable, Dict, Any, Set
import unittest
class TrtConvertGroupNormTest(TrtLayerAutoScanTest): class TrtConvertGroupNormTest(TrtLayerAutoScanTest):
......
...@@ -18,6 +18,7 @@ import numpy as np ...@@ -18,6 +18,7 @@ import numpy as np
import paddle.inference as paddle_infer import paddle.inference as paddle_infer
from functools import partial from functools import partial
from typing import Optional, List, Callable, Dict, Any, Set from typing import Optional, List, Callable, Dict, Any, Set
import unittest
class TrtConvertPreluTest(TrtLayerAutoScanTest): class TrtConvertPreluTest(TrtLayerAutoScanTest):
...@@ -186,6 +187,19 @@ 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." "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): def test(self):
self.add_skip_trt_case() self.add_skip_trt_case()
self.run_test() self.run_test()
......
...@@ -18,6 +18,7 @@ import numpy as np ...@@ -18,6 +18,7 @@ import numpy as np
import paddle.inference as paddle_infer import paddle.inference as paddle_infer
from functools import partial from functools import partial
from typing import Optional, List, Callable, Dict, Any, Set from typing import Optional, List, Callable, Dict, Any, Set
import unittest
class TrtConvertReshapeTest(TrtLayerAutoScanTest): class TrtConvertReshapeTest(TrtLayerAutoScanTest):
......
...@@ -18,6 +18,7 @@ import numpy as np ...@@ -18,6 +18,7 @@ import numpy as np
import paddle.inference as paddle_infer import paddle.inference as paddle_infer
from functools import partial from functools import partial
from typing import Optional, List, Callable, Dict, Any, Set from typing import Optional, List, Callable, Dict, Any, Set
import unittest
class TrtConvertScaleTest(TrtLayerAutoScanTest): class TrtConvertScaleTest(TrtLayerAutoScanTest):
......
...@@ -18,6 +18,7 @@ import numpy as np ...@@ -18,6 +18,7 @@ import numpy as np
import paddle.inference as paddle_infer import paddle.inference as paddle_infer
from functools import partial from functools import partial
from typing import Optional, List, Callable, Dict, Any, Set from typing import Optional, List, Callable, Dict, Any, Set
import unittest
class TrtConvertShuffleChannelTest(TrtLayerAutoScanTest): class TrtConvertShuffleChannelTest(TrtLayerAutoScanTest):
......
...@@ -18,6 +18,7 @@ import numpy as np ...@@ -18,6 +18,7 @@ import numpy as np
import paddle.inference as paddle_infer import paddle.inference as paddle_infer
from functools import partial from functools import partial
from typing import Optional, List, Callable, Dict, Any, Set from typing import Optional, List, Callable, Dict, Any, Set
import unittest
class TrtConvertSwishTest(TrtLayerAutoScanTest): class TrtConvertSwishTest(TrtLayerAutoScanTest):
......
...@@ -18,6 +18,7 @@ import numpy as np ...@@ -18,6 +18,7 @@ import numpy as np
import paddle.inference as paddle_infer import paddle.inference as paddle_infer
from functools import partial from functools import partial
from typing import Optional, List, Callable, Dict, Any, Set from typing import Optional, List, Callable, Dict, Any, Set
import unittest
class TrtConvertTransposeTest(TrtLayerAutoScanTest): class TrtConvertTransposeTest(TrtLayerAutoScanTest):
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册