From d150c3a6d73ee393a6289b9bb6872f3c3a730d54 Mon Sep 17 00:00:00 2001 From: Yuanle Liu Date: Mon, 26 Sep 2022 17:00:22 +0800 Subject: [PATCH] test=infer-coverage fix passes test bug on A10 (#46480) --- .gitignore | 1 + ...est_conv_elementwise_add2_act_fuse_pass.py | 47 +++++++++++-------- ...test_conv_elementwise_add_act_fuse_pass.py | 15 +++--- .../test_conv_eltwiseadd_bn_fuse_pass.py | 14 +++--- 4 files changed, 40 insertions(+), 37 deletions(-) diff --git a/.gitignore b/.gitignore index 4b53cfd8591..4ddcff8adc7 100644 --- a/.gitignore +++ b/.gitignore @@ -53,6 +53,7 @@ model_test Testing tools/__pycache__ +tools/nvcc_lazy # This file is automatically generated. # TODO(zhiqiang) Move this file to build directory. diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_conv_elementwise_add2_act_fuse_pass.py b/python/paddle/fluid/tests/unittests/ir/inference/test_conv_elementwise_add2_act_fuse_pass.py index 90848f58a54..2279db872c6 100755 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_conv_elementwise_add2_act_fuse_pass.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_conv_elementwise_add2_act_fuse_pass.py @@ -12,18 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -from auto_scan_test import PassAutoScanTest, SkipReasons +from auto_scan_test import PassAutoScanTest from program_config import TensorConfig, ProgramConfig, OpConfig 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 - -import hypothesis -from hypothesis import given, settings, seed, example, assume, reproduce_failure +import os import hypothesis.strategies as st +os.environ['NVIDIA_TF32_OVERRIDE'] = '0' + class TestConvElementwiseAdd2ActPass(PassAutoScanTest): """ @@ -62,11 +59,11 @@ class TestConvElementwiseAdd2ActPass(PassAutoScanTest): return False if padding_algorithm == "VALID": if int(((input_shape[2] - (dilations[0] * (filter_shape[2] - 1) + 1)) / strides[0] + 1)) <= 0 or \ - int(((input_shape[3] - (dilations[1] * (filter_shape[3] - 1) + 1)) / strides[1] + 1)) <= 0: + int(((input_shape[3] - (dilations[1] * (filter_shape[3] - 1) + 1)) / strides[1] + 1)) <= 0: return False if padding_algorithm == "EXPLICIT": if int(((input_shape[2] + paddings[0] + paddings[1] - (dilations[0] * (filter_shape[2] - 1) + 1)) / strides[0] + 1)) <= 0 or \ - int(((input_shape[3] + paddings[2] + paddings[3] - (dilations[1] * (filter_shape[3] - 1) + 1)) / strides[1] + 1)) <= 0: + int(((input_shape[3] + paddings[2] + paddings[3] - (dilations[1] * (filter_shape[3] - 1) + 1)) / strides[1] + 1)) <= 0: return False if padding_algorithm == "SAME": if int((input_shape[2] + strides[0] - 1) / strides[0]) <= 0 or int( @@ -137,17 +134,27 @@ class TestConvElementwiseAdd2ActPass(PassAutoScanTest): # 9. Generate legal elemntwise_add: X of conv2d bias_2_dict = dict() - bias_2_dict[1] = [x_shape[0], f_shape[0], \ - int(((x_shape[2] + padding[0] + padding[1] - (dilations[0] * (f_shape[2] - 1) + 1)) / strides[0] + 1)), \ - int(((x_shape[3] + padding[2] + padding[3] - (dilations[1] * (f_shape[3] - 1) + 1)) / strides[1] + 1))] - - bias_2_dict[2] = [x_shape[0], f_shape[0], \ - int((x_shape[2] + strides[0] - 1) / strides[0]), \ - int((x_shape[3] + strides[1] - 1) / strides[1])] - - bias_2_dict[3] = [x_shape[0], f_shape[0], \ - int(((x_shape[2] - (dilations[0] * (f_shape[2] - 1) + 1)) / strides[0] + 1)), \ - int(((x_shape[3] - (dilations[1] * (f_shape[3] - 1) + 1)) / strides[1] + 1))] + bias_2_dict[1] = [ + x_shape[0], f_shape[0], + int(((x_shape[2] + padding[0] + padding[1] - + (dilations[0] * (f_shape[2] - 1) + 1)) / strides[0] + 1)), + int(((x_shape[3] + padding[2] + padding[3] - + (dilations[1] * (f_shape[3] - 1) + 1)) / strides[1] + 1)) + ] + + bias_2_dict[2] = [ + x_shape[0], f_shape[0], + int((x_shape[2] + strides[0] - 1) / strides[0]), + int((x_shape[3] + strides[1] - 1) / strides[1]) + ] + + bias_2_dict[3] = [ + x_shape[0], f_shape[0], + int(((x_shape[2] - (dilations[0] * + (f_shape[2] - 1) + 1)) / strides[0] + 1)), + int(((x_shape[3] - (dilations[1] * + (f_shape[3] - 1) + 1)) / strides[1] + 1)) + ] bias_index = 1 if padding_algorithm == "SAME": bias_index = 2 diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_conv_elementwise_add_act_fuse_pass.py b/python/paddle/fluid/tests/unittests/ir/inference/test_conv_elementwise_add_act_fuse_pass.py index 72e15c04d99..8756625eaf1 100755 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_conv_elementwise_add_act_fuse_pass.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_conv_elementwise_add_act_fuse_pass.py @@ -12,18 +12,15 @@ # See the License for the specific language governing permissions and # limitations under the License. -from auto_scan_test import PassAutoScanTest, IgnoreReasons +from auto_scan_test import PassAutoScanTest from program_config import TensorConfig, ProgramConfig, OpConfig 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 - -import hypothesis -from hypothesis import given, settings, seed, example, assume, reproduce_failure +import os import hypothesis.strategies as st +os.environ['NVIDIA_TF32_OVERRIDE'] = '0' + class TestConvElementwiseAddActPass(PassAutoScanTest): """ @@ -60,11 +57,11 @@ class TestConvElementwiseAddActPass(PassAutoScanTest): return False if padding_algorithm == "VALID": if ((input_shape[2] - (dilations[0] * (filter_shape[2] - 1) + 1)) / strides[0] + 1) <= 1 or \ - ((input_shape[3] - (dilations[1] * (filter_shape[3] - 1) + 1)) / strides[1] + 1) <= 1: + ((input_shape[3] - (dilations[1] * (filter_shape[3] - 1) + 1)) / strides[1] + 1) <= 1: return False if padding_algorithm == "EXPLICIT": if ((input_shape[2] + paddings[0] + paddings[1] - (dilations[0] * (filter_shape[2] - 1) + 1)) / strides[0] + 1) <= 1 or \ - ((input_shape[3] + paddings[2] + paddings[3] - (dilations[1] * (filter_shape[3] - 1) + 1)) / strides[1] + 1) <= 1: + ((input_shape[3] + paddings[2] + paddings[3] - (dilations[1] * (filter_shape[3] - 1) + 1)) / strides[1] + 1) <= 1: return False if data_format == "NCHW": if input_shape[1] != filter_shape[1] * groups: diff --git a/python/paddle/fluid/tests/unittests/ir/inference/test_conv_eltwiseadd_bn_fuse_pass.py b/python/paddle/fluid/tests/unittests/ir/inference/test_conv_eltwiseadd_bn_fuse_pass.py index 363ba4d765e..1fb0612c402 100755 --- a/python/paddle/fluid/tests/unittests/ir/inference/test_conv_eltwiseadd_bn_fuse_pass.py +++ b/python/paddle/fluid/tests/unittests/ir/inference/test_conv_eltwiseadd_bn_fuse_pass.py @@ -12,18 +12,16 @@ # See the License for the specific language governing permissions and # limitations under the License. -from auto_scan_test import PassAutoScanTest, SkipReasons +from auto_scan_test import PassAutoScanTest from program_config import TensorConfig, ProgramConfig, OpConfig 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 +import os -import hypothesis -from hypothesis import given, settings, seed, example, assume, reproduce_failure import hypothesis.strategies as st +os.environ['NVIDIA_TF32_OVERRIDE'] = '0' + class TestConvEltwiseaddBnFusePass(PassAutoScanTest): """ @@ -69,11 +67,11 @@ class TestConvEltwiseaddBnFusePass(PassAutoScanTest): return False if padding_algorithm == "VALID": if ((input_shape[2] - (dilations[0] * (filter_shape[2] - 1) + 1)) / strides[0] + 1) <= 1 or \ - ((input_shape[3] - (dilations[1] * (filter_shape[3] - 1) + 1)) / strides[1] + 1) <= 1: + ((input_shape[3] - (dilations[1] * (filter_shape[3] - 1) + 1)) / strides[1] + 1) <= 1: return False if padding_algorithm == "EXPLICIT": if ((input_shape[2] + paddings[0] + paddings[1] - (dilations[0] * (filter_shape[2] - 1) + 1)) / strides[0] + 1) <= 1 or \ - ((input_shape[3] + paddings[2] + paddings[3] - (dilations[1] * (filter_shape[3] - 1) + 1)) / strides[1] + 1) <= 1: + ((input_shape[3] + paddings[2] + paddings[3] - (dilations[1] * (filter_shape[3] - 1) + 1)) / strides[1] + 1) <= 1: return False if data_format == "NCHW": -- GitLab