From b0b7516978ca542a12602d478aeb299ce92afdb9 Mon Sep 17 00:00:00 2001 From: zlsh80826 Date: Wed, 13 Apr 2022 14:42:28 +0800 Subject: [PATCH] Reduce trt convert unit test problem size (#41701) --- .../inference/test_trt_convert_activation.py | 34 +++++----- .../inference/test_trt_convert_batch_norm.py | 20 +++--- .../ir/inference/test_trt_convert_clip.py | 34 +++++----- .../ir/inference/test_trt_convert_conv2d.py | 64 +++++-------------- .../test_trt_convert_conv2d_fusion.py | 47 +++++--------- .../inference/test_trt_convert_elementwise.py | 14 ++-- .../ir/inference/test_trt_convert_gelu.py | 32 +++++----- .../test_trt_convert_hard_sigmoid.py | 16 ++--- .../inference/test_trt_convert_hard_swish.py | 8 +-- .../ir/inference/test_trt_convert_prelu.py | 8 +-- .../ir/inference/test_trt_convert_scale.py | 6 +- .../ir/inference/test_trt_convert_stack.py | 2 +- .../ir/inference/test_trt_convert_yolo_box.py | 14 ++-- 13 files changed, 122 insertions(+), 177 deletions(-) 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 bc40d3b4c27..c7f724bdaae 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 @@ -28,16 +28,16 @@ class TrtConvertActivationTest(TrtLayerAutoScanTest): def sample_program_configs(self): def generate_input1(dims, batch, attrs: List[Dict[str, Any]]): if dims == 1: - return np.ones([64]).astype(np.float32) + return np.ones([32]).astype(np.float32) elif dims == 2: - return np.ones([3, 64]).astype(np.float32) + return np.ones([3, 32]).astype(np.float32) elif dims == 3: - return np.ones([3, 64, 64]).astype(np.float32) + return np.ones([3, 32, 32]).astype(np.float32) else: - return np.ones([batch, 3, 64, 64]).astype(np.float32) + return np.ones([batch, 3, 32, 32]).astype(np.float32) for dims in [1, 2, 3, 4]: - for batch in [1, 2, 4]: + for batch in [1, 4]: for op_type in ["relu", "sigmoid", "tanh", "relu6"]: self.dims = dims dics = [{}] @@ -70,27 +70,25 @@ class TrtConvertActivationTest(TrtLayerAutoScanTest): def generate_dynamic_shape(attrs): if self.dims == 1: self.dynamic_shape.min_input_shape = {"input_data": [1]} - self.dynamic_shape.max_input_shape = {"input_data": [128]} - self.dynamic_shape.opt_input_shape = {"input_data": [64]} + self.dynamic_shape.max_input_shape = {"input_data": [64]} + self.dynamic_shape.opt_input_shape = {"input_data": [32]} elif self.dims == 2: - self.dynamic_shape.min_input_shape = {"input_data": [1, 32]} - self.dynamic_shape.max_input_shape = {"input_data": [4, 64]} - self.dynamic_shape.opt_input_shape = {"input_data": [3, 64]} + self.dynamic_shape.min_input_shape = {"input_data": [1, 16]} + self.dynamic_shape.max_input_shape = {"input_data": [4, 32]} + self.dynamic_shape.opt_input_shape = {"input_data": [3, 32]} elif self.dims == 3: - self.dynamic_shape.min_input_shape = {"input_data": [1, 32, 32]} - self.dynamic_shape.max_input_shape = { - "input_data": [10, 64, 64] - } - self.dynamic_shape.opt_input_shape = {"input_data": [3, 64, 64]} + self.dynamic_shape.min_input_shape = {"input_data": [1, 16, 16]} + self.dynamic_shape.max_input_shape = {"input_data": [4, 32, 32]} + self.dynamic_shape.opt_input_shape = {"input_data": [3, 32, 32]} else: self.dynamic_shape.min_input_shape = { - "input_data": [1, 3, 32, 32] + "input_data": [1, 3, 16, 16] } self.dynamic_shape.max_input_shape = { - "input_data": [4, 3, 64, 64] + "input_data": [4, 3, 32, 32] } self.dynamic_shape.opt_input_shape = { - "input_data": [1, 3, 64, 64] + "input_data": [1, 3, 32, 32] } def clear_dynamic_shape(): diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_batch_norm.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_batch_norm.py index 410cef798aa..899cf0e2639 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_batch_norm.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_batch_norm.py @@ -54,7 +54,7 @@ class TrtConvertBatchNormTest(TrtLayerAutoScanTest): for dims in [2, 3, 4]: for num_input in [0, 1]: - for batch in [1, 2, 4]: + for batch in [1, 4]: for epsilon in [1e-6, 1e-5, 1e-4]: for data_layout in ["NCHW"]: for momentum in [0.9, 0.8]: @@ -134,33 +134,33 @@ class TrtConvertBatchNormTest(TrtLayerAutoScanTest): if self.dims == 4: if attrs[0]['data_layout'] == "NCHW": self.dynamic_shape.min_input_shape = { - "batch_norm_input": [1, 3, 24, 24] + "batch_norm_input": [1, 3, 12, 12] } self.dynamic_shape.max_input_shape = { - "batch_norm_input": [4, 3, 48, 48] + "batch_norm_input": [4, 3, 24, 24] } self.dynamic_shape.opt_input_shape = { - "batch_norm_input": [1, 3, 24, 48] + "batch_norm_input": [1, 3, 24, 24] } elif attrs[0]['data_layout'] == "NHWC": self.dynamic_shape.min_input_shape = { - "batch_norm_input": [1, 24, 24, 3] + "batch_norm_input": [1, 12, 12, 3] } self.dynamic_shape.max_input_shape = { - "batch_norm_input": [4, 48, 48, 3] + "batch_norm_input": [4, 24, 24, 3] } self.dynamic_shape.opt_input_shape = { - "batch_norm_input": [1, 24, 48, 3] + "batch_norm_input": [1, 24, 24, 3] } elif self.dims == 3: self.dynamic_shape.min_input_shape = { - "batch_norm_input": [1, 3, 24] + "batch_norm_input": [1, 3, 12] } self.dynamic_shape.max_input_shape = { - "batch_norm_input": [4, 3, 48] + "batch_norm_input": [4, 3, 24] } self.dynamic_shape.opt_input_shape = { - "batch_norm_input": [1, 3, 48] + "batch_norm_input": [1, 3, 24] } elif self.dims == 2: self.dynamic_shape.min_input_shape = { diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_clip.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_clip.py index 5150622cf80..1277cde011c 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_clip.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_clip.py @@ -28,13 +28,13 @@ class TrtConvertClipTest(TrtLayerAutoScanTest): def sample_program_configs(self): def generate_input1(dims, batch, attrs: List[Dict[str, Any]]): if dims == 1: - return np.ones([64]).astype(np.float32) + return np.ones([32]).astype(np.float32) elif dims == 2: - return np.ones([3, 64]).astype(np.float32) + return np.ones([3, 32]).astype(np.float32) elif dims == 3: - return np.ones([3, 64, 64]).astype(np.float32) + return np.ones([3, 32, 32]).astype(np.float32) else: - return np.ones([batch, 3, 64, 64]).astype(np.float32) + return np.ones([batch, 3, 32, 32]).astype(np.float32) def generate_weight1(attrs: List[Dict[str, Any]]): return np.array([np.random.uniform(1, 10)]).astype("float32") @@ -43,7 +43,7 @@ class TrtConvertClipTest(TrtLayerAutoScanTest): return np.array([np.random.uniform(10, 20)]).astype("float32") for dims in [1, 2, 3, 4]: - for batch in [1, 2, 4]: + for batch in [1, 4]: for op_inputs in [{ "X": ["input_data"] }, { @@ -89,27 +89,25 @@ class TrtConvertClipTest(TrtLayerAutoScanTest): def generate_dynamic_shape(attrs): if self.dims == 1: self.dynamic_shape.min_input_shape = {"input_data": [1]} - self.dynamic_shape.max_input_shape = {"input_data": [128]} - self.dynamic_shape.opt_input_shape = {"input_data": [64]} + self.dynamic_shape.max_input_shape = {"input_data": [64]} + self.dynamic_shape.opt_input_shape = {"input_data": [32]} elif self.dims == 2: - self.dynamic_shape.min_input_shape = {"input_data": [1, 32]} - self.dynamic_shape.max_input_shape = {"input_data": [4, 64]} - self.dynamic_shape.opt_input_shape = {"input_data": [3, 64]} + self.dynamic_shape.min_input_shape = {"input_data": [1, 16]} + self.dynamic_shape.max_input_shape = {"input_data": [4, 32]} + self.dynamic_shape.opt_input_shape = {"input_data": [3, 32]} elif self.dims == 3: - self.dynamic_shape.min_input_shape = {"input_data": [1, 32, 32]} - self.dynamic_shape.max_input_shape = { - "input_data": [10, 64, 64] - } - self.dynamic_shape.opt_input_shape = {"input_data": [3, 64, 64]} + self.dynamic_shape.min_input_shape = {"input_data": [1, 16, 16]} + self.dynamic_shape.max_input_shape = {"input_data": [4, 32, 32]} + self.dynamic_shape.opt_input_shape = {"input_data": [3, 32, 32]} else: self.dynamic_shape.min_input_shape = { - "input_data": [1, 3, 32, 32] + "input_data": [1, 3, 16, 16] } self.dynamic_shape.max_input_shape = { - "input_data": [4, 3, 64, 64] + "input_data": [4, 3, 32, 32] } self.dynamic_shape.opt_input_shape = { - "input_data": [1, 3, 64, 64] + "input_data": [1, 3, 32, 32] } def clear_dynamic_shape(): diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d.py index 5f85debf4b2..84ef5b4da68 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d.py @@ -46,20 +46,16 @@ class TrtConvertConv2dTest(TrtLayerAutoScanTest): self.trt_param.workspace_size = 1073741824 def generate_input1(batch, attrs: List[Dict[str, Any]]): - if attrs[0]['groups'] == 1: - return np.ones([batch, 3, 64, 64]).astype(np.float32) - elif attrs[0]['groups'] == 2: - return np.ones([batch, 6, 64, 64]).astype(np.float32) - else: - return np.ones([batch, 9, 64, 64]).astype(np.float32) + return np.ones( + [batch, attrs[0]['groups'] * 3, 64, 64]).astype(np.float32) def generate_weight1(attrs: List[Dict[str, Any]]): return np.random.random([24, 3, 3, 3]).astype(np.float32) - for batch in [1, 2, 4]: + for batch in [1, 4]: for strides in [[1, 1], [2, 2], [1, 2]]: for paddings in [[0, 3], [1, 2, 3, 4]]: - for groups in [1, 2, 3]: + for groups in [1, 3]: for padding_algorithm in ['EXPLICIT', 'SAME', 'VALID']: for dilations in [[1, 1], [2, 2], [1, 2]]: for data_format in ['NCHW']: @@ -116,45 +112,19 @@ class TrtConvertConv2dTest(TrtLayerAutoScanTest): def sample_predictor_configs( self, program_config) -> (paddle_infer.Config, List[int], float): def generate_dynamic_shape(attrs): - if attrs[0]['groups'] == 1: - self.dynamic_shape.min_input_shape = { - "input_data": [1, 3, 32, 32], - "output_data": [1, 24, 32, 32] - } - self.dynamic_shape.max_input_shape = { - "input_data": [4, 3, 64, 64], - "output_data": [4, 24, 64, 64] - } - self.dynamic_shape.opt_input_shape = { - "input_data": [1, 3, 64, 64], - "output_data": [1, 24, 64, 64] - } - elif attrs[0]['groups'] == 2: - self.dynamic_shape.min_input_shape = { - "input_data": [1, 6, 32, 32], - "output_data": [1, 24, 32, 32] - } - self.dynamic_shape.max_input_shape = { - "input_data": [4, 6, 64, 64], - "output_data": [4, 24, 64, 64] - } - self.dynamic_shape.opt_input_shape = { - "input_data": [1, 6, 64, 64], - "output_data": [1, 24, 64, 64] - } - else: - self.dynamic_shape.min_input_shape = { - "input_data": [1, 9, 32, 32], - "output_data": [1, 24, 32, 32] - } - self.dynamic_shape.max_input_shape = { - "input_data": [4, 9, 64, 64], - "output_data": [4, 24, 64, 64] - } - self.dynamic_shape.opt_input_shape = { - "input_data": [1, 9, 64, 64], - "output_data": [1, 24, 64, 64] - } + input_groups = attrs[0]['groups'] * 3 + self.dynamic_shape.min_input_shape = { + "input_data": [1, input_groups, 32, 32], + "output_data": [1, 24, 32, 32] + } + self.dynamic_shape.max_input_shape = { + "input_data": [4, input_groups, 64, 64], + "output_data": [4, 24, 64, 64] + } + self.dynamic_shape.opt_input_shape = { + "input_data": [1, input_groups, 64, 64], + "output_data": [1, 24, 64, 64] + } def clear_dynamic_shape(): self.dynamic_shape.min_input_shape = {} diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d_fusion.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d_fusion.py index b1b5626c10e..8a9a9909571 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d_fusion.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_conv2d_fusion.py @@ -49,10 +49,8 @@ class TrtConvertConv2dFusionTest(TrtLayerAutoScanTest): self.trt_param.workspace_size = 1073741824 def generate_input1(batch, attrs: List[Dict[str, Any]]): - if attrs[0]['groups'] == 2: - return np.ones([batch, 6, 64, 64]).astype(np.float32) - else: - return np.ones([batch, 9, 64, 64]).astype(np.float32) + return np.ones( + [batch, attrs[0]['groups'] * 3, 64, 64]).astype(np.float32) def generate_weight1(attrs: List[Dict[str, Any]]): return np.random.random([24, 3, 3, 3]).astype(np.float32) @@ -60,7 +58,7 @@ class TrtConvertConv2dFusionTest(TrtLayerAutoScanTest): def generate_weight2(attrs: List[Dict[str, Any]]): return np.random.random([24, 1, 1]).astype(np.float32) - for batch in [1, 2, 4]: + for batch in [1, 4]: for strides in [[1, 1], [2, 2], [1, 2]]: for paddings in [[0, 3], [1, 2, 3, 4]]: for groups in [2, 3]: @@ -126,32 +124,19 @@ class TrtConvertConv2dFusionTest(TrtLayerAutoScanTest): def sample_predictor_configs( self, program_config) -> (paddle_infer.Config, List[int], float): def generate_dynamic_shape(attrs): - if attrs[0]['groups'] == 2: - self.dynamic_shape.min_input_shape = { - "input_data": [1, 6, 32, 32], - "output_data": [1, 24, 32, 32] - } - self.dynamic_shape.max_input_shape = { - "input_data": [4, 6, 64, 64], - "output_data": [4, 24, 64, 64] - } - self.dynamic_shape.opt_input_shape = { - "input_data": [1, 6, 64, 64], - "output_data": [1, 24, 64, 64] - } - else: - self.dynamic_shape.min_input_shape = { - "input_data": [1, 9, 32, 32], - "output_data": [1, 24, 32, 32] - } - self.dynamic_shape.max_input_shape = { - "input_data": [4, 9, 64, 64], - "output_data": [4, 24, 64, 64] - } - self.dynamic_shape.opt_input_shape = { - "input_data": [1, 9, 64, 64], - "output_data": [1, 24, 64, 64] - } + input_groups = attrs[0]['groups'] * 3 + self.dynamic_shape.min_input_shape = { + "input_data": [1, input_groups, 32, 32], + "output_data": [1, 24, 32, 32] + } + self.dynamic_shape.max_input_shape = { + "input_data": [4, input_groups, 64, 64], + "output_data": [4, 24, 64, 64] + } + self.dynamic_shape.opt_input_shape = { + "input_data": [1, input_groups, 64, 64], + "output_data": [1, 24, 64, 64] + } def clear_dynamic_shape(): self.dynamic_shape.min_input_shape = {} 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 e849496621a..ec02a357a48 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 @@ -32,7 +32,7 @@ class TrtConvertElementwiseTest_one_input(TrtLayerAutoScanTest): def generate_weight(): return np.random.randn(32).astype(np.float32) - for batch in [1, 2, 4]: + for batch in [1, 4]: for shape in [[32], [batch, 32], [batch, 32, 32], [batch, 32, 16, 32]]: for op_type in ["elementwise_add", "elementwise_mul"]: @@ -72,7 +72,7 @@ class TrtConvertElementwiseTest_one_input(TrtLayerAutoScanTest): # The input.dims[1] must be equal to the weight's length. if self.dims == 1: self.dynamic_shape.min_input_shape = {"input_data": [4]} - self.dynamic_shape.max_input_shape = {"input_data": [256]} + self.dynamic_shape.max_input_shape = {"input_data": [32]} self.dynamic_shape.opt_input_shape = {"input_data": [16]} elif self.dims == 2: self.dynamic_shape.min_input_shape = {"input_data": [1, 32]} @@ -80,19 +80,17 @@ class TrtConvertElementwiseTest_one_input(TrtLayerAutoScanTest): self.dynamic_shape.opt_input_shape = {"input_data": [2, 32]} elif self.dims == 3: self.dynamic_shape.min_input_shape = {"input_data": [1, 32, 4]} - self.dynamic_shape.max_input_shape = { - "input_data": [4, 32, 256] - } - self.dynamic_shape.opt_input_shape = {"input_data": [2, 32, 16]} + self.dynamic_shape.max_input_shape = {"input_data": [4, 32, 32]} + self.dynamic_shape.opt_input_shape = {"input_data": [2, 32, 32]} elif self.dims == 4: self.dynamic_shape.min_input_shape = { "input_data": [1, 32, 4, 4] } self.dynamic_shape.max_input_shape = { - "input_data": [4, 32, 128, 256] + "input_data": [4, 32, 32, 32] } self.dynamic_shape.opt_input_shape = { - "input_data": [2, 32, 32, 16] + "input_data": [4, 32, 16, 32] } def clear_dynamic_shape(): 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 e79b33d88d3..448e4e3e71b 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 @@ -28,13 +28,13 @@ class TrtConvertGeluTest(TrtLayerAutoScanTest): def sample_program_configs(self): def generate_input1(dims, attrs: List[Dict[str, Any]]): if dims == 1: - return np.ones([64]).astype(np.float32) + return np.ones([32]).astype(np.float32) elif dims == 2: - return np.ones([3, 64]).astype(np.float32) + return np.ones([3, 32]).astype(np.float32) elif dims == 3: - return np.ones([3, 64, 64]).astype(np.float32) + return np.ones([3, 32, 32]).astype(np.float32) else: - return np.ones([1, 3, 64, 64]).astype(np.float32) + return np.ones([1, 3, 32, 32]).astype(np.float32) for dims in [1, 2, 3, 4]: for approximate in [True, False]: @@ -69,27 +69,25 @@ class TrtConvertGeluTest(TrtLayerAutoScanTest): def generate_dynamic_shape(attrs): if self.dims == 1: self.dynamic_shape.min_input_shape = {"input_data": [1]} - self.dynamic_shape.max_input_shape = {"input_data": [128]} - self.dynamic_shape.opt_input_shape = {"input_data": [64]} + self.dynamic_shape.max_input_shape = {"input_data": [64]} + self.dynamic_shape.opt_input_shape = {"input_data": [32]} elif self.dims == 2: - self.dynamic_shape.min_input_shape = {"input_data": [1, 32]} - self.dynamic_shape.max_input_shape = {"input_data": [4, 64]} - self.dynamic_shape.opt_input_shape = {"input_data": [3, 64]} + self.dynamic_shape.min_input_shape = {"input_data": [1, 16]} + self.dynamic_shape.max_input_shape = {"input_data": [4, 32]} + self.dynamic_shape.opt_input_shape = {"input_data": [3, 32]} elif self.dims == 3: - self.dynamic_shape.min_input_shape = {"input_data": [1, 32, 32]} - self.dynamic_shape.max_input_shape = { - "input_data": [10, 64, 64] - } - self.dynamic_shape.opt_input_shape = {"input_data": [3, 64, 64]} + self.dynamic_shape.min_input_shape = {"input_data": [1, 16, 16]} + self.dynamic_shape.max_input_shape = {"input_data": [4, 32, 32]} + self.dynamic_shape.opt_input_shape = {"input_data": [3, 32, 32]} else: self.dynamic_shape.min_input_shape = { - "input_data": [1, 3, 32, 32] + "input_data": [1, 3, 16, 16] } self.dynamic_shape.max_input_shape = { - "input_data": [4, 3, 64, 64] + "input_data": [4, 3, 32, 32] } self.dynamic_shape.opt_input_shape = { - "input_data": [1, 3, 64, 64] + "input_data": [1, 3, 32, 32] } def clear_dynamic_shape(): diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_hard_sigmoid.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_hard_sigmoid.py index 969f0e8b148..b3f118e9fbf 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_hard_sigmoid.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_hard_sigmoid.py @@ -29,8 +29,8 @@ class TrtConvertHardSigmoidTest_dim_2(TrtLayerAutoScanTest): def generate_input(shape): return np.random.random(shape).astype(np.float32) - for batch in [1, 2, 4]: - for shape in [[batch, 64], [batch, 32, 64], [batch, 64, 32, 128]]: + for batch in [1, 4]: + for shape in [[batch, 32], [batch, 16, 32], [batch, 32, 16, 128]]: self.input_dim = len(shape) for slope in [0.1, 0.5]: for offset in [0.2, 0.7]: @@ -63,23 +63,21 @@ class TrtConvertHardSigmoidTest_dim_2(TrtLayerAutoScanTest): def generate_dynamic_shape(attrs): if self.input_dim == 2: self.dynamic_shape.min_input_shape = {"input_data": [1, 8]} - self.dynamic_shape.max_input_shape = {"input_data": [64, 128]} + self.dynamic_shape.max_input_shape = {"input_data": [4, 32]} self.dynamic_shape.opt_input_shape = {"input_data": [2, 16]} elif self.input_dim == 3: self.dynamic_shape.min_input_shape = {"input_data": [1, 8, 8]} - self.dynamic_shape.max_input_shape = { - "input_data": [64, 128, 256] - } - self.dynamic_shape.opt_input_shape = {"input_data": [2, 16, 64]} + self.dynamic_shape.max_input_shape = {"input_data": [4, 16, 32]} + self.dynamic_shape.opt_input_shape = {"input_data": [4, 16, 32]} elif self.input_dim == 4: self.dynamic_shape.min_input_shape = { "input_data": [1, 8, 8, 4] } self.dynamic_shape.max_input_shape = { - "input_data": [64, 128, 256, 512] + "input_data": [4, 32, 16, 128] } self.dynamic_shape.opt_input_shape = { - "input_data": [2, 16, 64, 128] + "input_data": [4, 32, 16, 128] } def clear_dynamic_shape(): diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_hard_swish.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_hard_swish.py index 283a19ec005..c092d6da868 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_hard_swish.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_hard_swish.py @@ -37,7 +37,7 @@ class TrtConvertHardSwishTest(TrtLayerAutoScanTest): def sample_program_configs(self): def generate_input1(attrs: List[Dict[str, Any]]): - return np.ones([1, 3, 64, 64]).astype(np.float32) + return np.ones([1, 3, 32, 32]).astype(np.float32) for threshold in [6.0, 7.0, 100.0, 0.0, -1.0]: for scale in [5.0, 6.0, 7.0, -1.0, 0.0, 100.0]: @@ -74,9 +74,9 @@ class TrtConvertHardSwishTest(TrtLayerAutoScanTest): def sample_predictor_configs( self, program_config) -> (paddle_infer.Config, List[int], float): def generate_dynamic_shape(attrs): - self.dynamic_shape.min_input_shape = {"input_data": [1, 3, 32, 32]} - self.dynamic_shape.max_input_shape = {"input_data": [4, 3, 64, 64]} - self.dynamic_shape.opt_input_shape = {"input_data": [1, 3, 64, 64]} + self.dynamic_shape.min_input_shape = {"input_data": [1, 3, 16, 16]} + self.dynamic_shape.max_input_shape = {"input_data": [2, 3, 32, 32]} + self.dynamic_shape.opt_input_shape = {"input_data": [1, 3, 32, 32]} def clear_dynamic_shape(): self.dynamic_shape.min_input_shape = {} 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 10109cdc73a..00e3f7feb60 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 @@ -136,7 +136,7 @@ class TrtConvertPreluTest(TrtLayerAutoScanTest): "input_data": [1, 1], } self.dynamic_shape.max_input_shape = { - "input_data": [4, 64], + "input_data": [4, 32], } self.dynamic_shape.opt_input_shape = { "input_data": [2, 3], @@ -146,7 +146,7 @@ class TrtConvertPreluTest(TrtLayerAutoScanTest): "input_data": [1, 1, 1, 1], } self.dynamic_shape.max_input_shape = { - "input_data": [4, 64, 128, 128], + "input_data": [4, 3, 16, 32], } self.dynamic_shape.opt_input_shape = { "input_data": [2, 3, 16, 32], @@ -156,10 +156,10 @@ class TrtConvertPreluTest(TrtLayerAutoScanTest): "input_data": [1, 1, 1], } self.dynamic_shape.max_input_shape = { - "input_data": [4, 64, 256], + "input_data": [4, 3, 32], } self.dynamic_shape.opt_input_shape = { - "input_data": [2, 3, 128], + "input_data": [2, 3, 16], } def clear_dynamic_shape(): 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 62e7a103277..d607a43739e 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 @@ -94,14 +94,14 @@ class TrtConvertScaleTest(TrtLayerAutoScanTest): "scale_input": [1, 3, 24, 24] } self.dynamic_shape.max_input_shape = { - "scale_input": [9, 3, 48, 48] + "scale_input": [4, 3, 24, 24] } self.dynamic_shape.opt_input_shape = { - "scale_input": [1, 3, 48, 24] + "scale_input": [1, 3, 24, 24] } elif self.dims == 3: self.dynamic_shape.min_input_shape = {"scale_input": [1, 3, 24]} - self.dynamic_shape.max_input_shape = {"scale_input": [9, 6, 48]} + self.dynamic_shape.max_input_shape = {"scale_input": [4, 3, 24]} self.dynamic_shape.opt_input_shape = {"scale_input": [1, 3, 24]} elif self.dims == 2: self.dynamic_shape.min_input_shape = {"scale_input": [1, 24]} diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_stack.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_stack.py index 93ba5da9d66..062312b0fab 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_stack.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_stack.py @@ -69,7 +69,7 @@ class TrtConvertStackTest(TrtLayerAutoScanTest): return np.ones([24]).astype(np.float32) for dims in [1, 2, 3, 4]: - for batch in [1, 2, 4]: + for batch in [1, 4]: for axis in [-2, -1, 0, 1, 2, 3]: self.dims = dims dics = [{"axis": axis}, {}] diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_yolo_box.py b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_yolo_box.py index 17955c6e007..269523661ee 100644 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_yolo_box.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_trt_convert_yolo_box.py @@ -37,7 +37,7 @@ class TrtConvertYoloBoxTest(TrtLayerAutoScanTest): def generate_input2(attrs: List[Dict[str, Any]], batch): return np.random.random([batch, 2]).astype(np.int32) - for batch in [1, 2, 4]: + for batch in [1, 4]: for class_num in [80, 30]: for anchors in [[10, 13, 16, 30, 33, 23]]: for downsample_ratio in [32, 16]: @@ -97,24 +97,24 @@ class TrtConvertYoloBoxTest(TrtLayerAutoScanTest): if attrs[0]['iou_aware'] == True: channel = 3 * (attrs[0]['class_num'] + 6) self.dynamic_shape.min_input_shape = { - "scale_input": [1, channel, 24, 24] + "scale_input": [1, channel, 12, 12] } self.dynamic_shape.max_input_shape = { - "scale_input": [4, channel, 48, 48] + "scale_input": [4, channel, 24, 24] } self.dynamic_shape.opt_input_shape = { - "scale_input": [1, channel, 24, 48] + "scale_input": [1, channel, 24, 24] } else: channel = 3 * (attrs[0]['class_num'] + 5) self.dynamic_shape.min_input_shape = { - "scale_input": [1, channel, 24, 24] + "scale_input": [1, channel, 12, 12] } self.dynamic_shape.max_input_shape = { - "scale_input": [4, channel, 48, 48] + "scale_input": [4, channel, 24, 24] } self.dynamic_shape.opt_input_shape = { - "scale_input": [1, channel, 24, 48] + "scale_input": [1, channel, 24, 24] } def clear_dynamic_shape(): -- GitLab