From d255bfe0203bb81b8c68b86d77ed14c350beaf52 Mon Sep 17 00:00:00 2001 From: JingZhuangzhuang <75348594+JZZ-NOTE@users.noreply.github.com> Date: Mon, 7 Mar 2022 13:25:57 +0800 Subject: [PATCH] fix_conv2d_trt_convert_test_case (#39882) * fix_conv2d_trt_convert_test_case * fix_conv2d_trt_convert_test_case * fix_conv2d_trt_convert_test_case * fix_conv2d_trt_convert_test_case --- .../test_trt_convert_conv2d_transpose.py | 44 ++++++------------- .../test_trt_convert_deformable_conv.py | 14 +----- ..._trt_convert_depthwise_conv2d_transpose.py | 44 ++++++------------- 3 files changed, 29 insertions(+), 73 deletions(-) diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d_transpose.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d_transpose.py index e21d67839eb..65fc35f9c56 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d_transpose.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d_transpose.py @@ -37,6 +37,13 @@ class TrtConvertConv2dTransposeTest(TrtLayerAutoScanTest): if inputs['input_data'].shape[1] != weights['conv2d_weight'].shape[0]: return False + if attrs[0]['dilations'][0] != 1 or attrs[0]['dilations'][1] != 1: + return False + + ver = paddle_infer.get_trt_compile_version() + if ver[0] * 1000 + ver[1] * 100 + ver[2] * 10 < 7000: + return False + return True def sample_program_configs(self): @@ -175,9 +182,9 @@ class TrtConvertConv2dTransposeTest(TrtLayerAutoScanTest): self.trt_param.precision = paddle_infer.PrecisionType.Half yield self.create_inference_config(), generate_trt_nodes_num( attrs, False), (1e-5, 1e-3) - self.trt_param.precision = paddle_infer.PrecisionType.Int8 - yield self.create_inference_config(), generate_trt_nodes_num( - attrs, False), (1e-5, 1e-5) + # self.trt_param.precision = paddle_infer.PrecisionType.Int8 + # yield self.create_inference_config(), generate_trt_nodes_num( + # attrs, False), (1e-5, 1e-5) # for dynamic_shape generate_dynamic_shape(attrs) @@ -187,41 +194,18 @@ class TrtConvertConv2dTransposeTest(TrtLayerAutoScanTest): self.trt_param.precision = paddle_infer.PrecisionType.Half yield self.create_inference_config(), generate_trt_nodes_num( attrs, True), (1e-5, 1e-3) - self.trt_param.precision = paddle_infer.PrecisionType.Int8 - yield self.create_inference_config(), generate_trt_nodes_num( - attrs, True), (1e-5, 1e-5) + # self.trt_param.precision = paddle_infer.PrecisionType.Int8 + # yield self.create_inference_config(), generate_trt_nodes_num( + # attrs, True), (1e-5, 1e-5) def add_skip_trt_case(self): def teller1(program_config, predictor_config): - if program_config.ops[0].attrs[ - 'padding_algorithm'] == "SAME" or program_config.ops[ - 0].attrs['padding_algorithm'] == "VALID": - return True - return False - - self.add_skip_case( - teller1, SkipReasons.TRT_NOT_IMPLEMENTED, - "When padding_algorithm is 'SAME' or 'VALID', Trt dose not support. In this case, trt build error is caused by scale op." - ) - - def teller2(program_config, predictor_config): - if program_config.ops[0].attrs['dilations'][ - 0] != 1 or program_config.ops[0].attrs['dilations'][1] != 1: - return True - return False - - self.add_skip_case( - teller2, SkipReasons.TRT_NOT_IMPLEMENTED, - "When dilations's element is not equal 1, there are different behaviors between Trt and Paddle." - ) - - def teller3(program_config, predictor_config): if self.trt_param.precision == paddle_infer.PrecisionType.Int8: return True return False self.add_skip_case( - teller3, SkipReasons.TRT_NOT_IMPLEMENTED, + teller1, SkipReasons.TRT_NOT_IMPLEMENTED, "When precisionType is int8 without relu op, output is different between Trt and Paddle." ) diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_deformable_conv.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_deformable_conv.py index 9d29034d7fe..c692e92861b 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_deformable_conv.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_deformable_conv.py @@ -147,7 +147,7 @@ class TrtConvertDeformableConvTest(TrtLayerAutoScanTest): if len(attrs[0]['paddings']) == 4: return 1, 2 else: - return 1, 2 + return 1, 4 attrs = [ program_config.ops[i].attrs @@ -160,20 +160,8 @@ class TrtConvertDeformableConvTest(TrtLayerAutoScanTest): yield self.create_inference_config(), generate_trt_nodes_num( attrs, False), 1e-5 - def add_skip_trt_case(self): - def teller1(program_config, predictor_config): - if len(program_config.ops[0].attrs["strides"]) != 2: - return False - - return True - - self.add_skip_case( - teller1, SkipReasons.TRT_NOT_IMPLEMENTED, - "In deformable conv, length of Attr(strides) should be 2.") - def test(self): self.trt_param.workspace_size = 1 << 28 - self.add_skip_trt_case() self.run_test() diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_depthwise_conv2d_transpose.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_depthwise_conv2d_transpose.py index 66a007f64b6..5f77e7de0df 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_depthwise_conv2d_transpose.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_depthwise_conv2d_transpose.py @@ -40,6 +40,13 @@ class TrtConvertDepthwiseConv2dTransposeTest(TrtLayerAutoScanTest): if inputs['input_data'].shape[1] != attrs[0]['groups']: return False + if attrs[0]['dilations'][0] != 1 or attrs[0]['dilations'][1] != 1: + return False + + ver = paddle_infer.get_trt_compile_version() + if ver[0] * 1000 + ver[1] * 100 + ver[2] * 10 < 7000: + return False + return True def sample_program_configs(self): @@ -139,9 +146,9 @@ class TrtConvertDepthwiseConv2dTransposeTest(TrtLayerAutoScanTest): self.trt_param.precision = paddle_infer.PrecisionType.Half yield self.create_inference_config(), generate_trt_nodes_num( attrs, False), (1e-5, 1e-3) - self.trt_param.precision = paddle_infer.PrecisionType.Int8 - yield self.create_inference_config(), generate_trt_nodes_num( - attrs, False), (1e-5, 1e-5) + # self.trt_param.precision = paddle_infer.PrecisionType.Int8 + # yield self.create_inference_config(), generate_trt_nodes_num( + # attrs, False), (1e-5, 1e-5) # for dynamic_shape generate_dynamic_shape(attrs) @@ -151,41 +158,18 @@ class TrtConvertDepthwiseConv2dTransposeTest(TrtLayerAutoScanTest): self.trt_param.precision = paddle_infer.PrecisionType.Half yield self.create_inference_config(), generate_trt_nodes_num( attrs, True), (1e-5, 1e-5) - self.trt_param.precision = paddle_infer.PrecisionType.Int8 - yield self.create_inference_config(), generate_trt_nodes_num( - attrs, True), (1e-5, 1e-5) + # self.trt_param.precision = paddle_infer.PrecisionType.Int8 + # yield self.create_inference_config(), generate_trt_nodes_num( + # attrs, True), (1e-5, 1e-5) def add_skip_trt_case(self): def teller1(program_config, predictor_config): - if program_config.ops[0].attrs[ - 'padding_algorithm'] == "SAME" or program_config.ops[ - 0].attrs['padding_algorithm'] == "VALID": - return True - return False - - self.add_skip_case( - teller1, SkipReasons.TRT_NOT_IMPLEMENTED, - "When padding_algorithm is 'SAME' or 'VALID', Trt dose not support. In this case, trt build error is caused by scale op." - ) - - def teller2(program_config, predictor_config): - if program_config.ops[0].attrs['dilations'][ - 0] != 1 or program_config.ops[0].attrs['dilations'][1] != 1: - return True - return False - - self.add_skip_case( - teller2, SkipReasons.TRT_NOT_IMPLEMENTED, - "When dilations's element is not equal 1, there are different behaviors between Trt and Paddle." - ) - - def teller3(program_config, predictor_config): if self.trt_param.precision == paddle_infer.PrecisionType.Int8: return True return False self.add_skip_case( - teller3, SkipReasons.TRT_NOT_IMPLEMENTED, + teller1, SkipReasons.TRT_NOT_IMPLEMENTED, "When precisionType is int8 without relu op, output is different between Trt and Paddle." ) -- GitLab