From b8e3a380c4149efbc342ab08c3cf43e2b9b7adc3 Mon Sep 17 00:00:00 2001 From: zhanghonggeng Date: Thu, 27 Feb 2025 06:36:45 +0000 Subject: [PATCH] update test_auto_scan_pool_adaptive_max_ops.py --- tests/run.bat | 1 - tests/run.sh | 1 - tests/test_auto_scan_pool_adaptive_max_ops.py | 62 +++++++++---------- 3 files changed, 29 insertions(+), 35 deletions(-) diff --git a/tests/run.bat b/tests/run.bat index 79d464ebd..0c9293fdb 100644 --- a/tests/run.bat +++ b/tests/run.bat @@ -33,7 +33,6 @@ for /R %%i in (test*.py) do ( REM List of files to ignore set ignore=test_auto_scan_multiclass_nms.py set ignore=!ignore! test_auto_scan_roi_align.py -set ignore=!ignore! test_auto_scan_pool_adaptive_max_ops.py set ignore=!ignore! test_auto_scan_pad2d.py set ignore=!ignore! test_auto_scan_uniform_random_batch_size_like.py set ignore=!ignore! test_auto_scan_uniform_random.py diff --git a/tests/run.sh b/tests/run.sh index 82bb956dc..8ca49c314 100755 --- a/tests/run.sh +++ b/tests/run.sh @@ -27,7 +27,6 @@ cases=$(find . -name "test*.py" | sort) ignore="test_auto_scan_multiclass_nms.py test_auto_scan_roi_align.py \ # need to be rewrite - test_auto_scan_pool_adaptive_max_ops.py \ test_auto_scan_pad2d.py \ test_auto_scan_uniform_random_batch_size_like.py \ test_auto_scan_uniform_random.py \ diff --git a/tests/test_auto_scan_pool_adaptive_max_ops.py b/tests/test_auto_scan_pool_adaptive_max_ops.py index 0d2da46a8..f00d721d7 100644 --- a/tests/test_auto_scan_pool_adaptive_max_ops.py +++ b/tests/test_auto_scan_pool_adaptive_max_ops.py @@ -13,11 +13,10 @@ # limitations under the License. from auto_scan_test import OPConvertAutoScanTest, BaseNet -from hypothesis import reproduce_failure import hypothesis.strategies as st -import numpy as np import unittest import paddle +from onnxbase import _test_with_pir class NetAvgPool1d(BaseNet): @@ -29,23 +28,23 @@ def forward(self, inputs): """ forward """ - output_size = self.config['output_size'] + output_size = self.config["output_size"] x = paddle.nn.functional.adaptive_max_pool1d( - inputs, output_size=output_size, return_mask=False) + inputs, output_size=output_size, return_mask=False + ) return x class TestAdaptiveAvgPool1dConvert(OPConvertAutoScanTest): """ api: paddle.nn.functional.adaptive_avg_pool1d - OPset version: 7, 9, 15 + OPset version: 9, 15 """ def sample_convert_config(self, draw): input_shape = draw( - st.lists( - st.integers( - min_value=10, max_value=12), min_size=3, max_size=3)) + st.lists(st.integers(min_value=10, max_value=12), min_size=3, max_size=3) + ) if input_shape[2] % 2 != 0: input_shape[2] = input_shape[2] + 1 @@ -58,7 +57,7 @@ def sample_convert_config(self, draw): "op_names": ["max_pool2d_with_index"], "test_data_shapes": [input_shape], "test_data_types": [[dtype]], - "opset_version": [7, 9, 15], + "opset_version": [9, 15], "input_spec_shape": [], "output_size": output_size, } @@ -67,6 +66,7 @@ def sample_convert_config(self, draw): return (config, models) + @_test_with_pir def test(self): self.run_and_statis(max_examples=30) @@ -81,23 +81,23 @@ def forward(self, inputs): """ forward """ - output_size = self.config['output_size'] + output_size = self.config["output_size"] x = paddle.nn.functional.adaptive_max_pool2d( - inputs, output_size, return_mask=False) + inputs, output_size, return_mask=False + ) return x class TestAdaptiveAvgPool2dConvert(OPConvertAutoScanTest): """ api: paddle.nn.functional.adaptive_avg_pool2d - OPset version: 7, 9, 15 + OPset version: 9, 15 """ def sample_convert_config(self, draw): input_shape = draw( - st.lists( - st.integers( - min_value=10, max_value=12), min_size=4, max_size=4)) + st.lists(st.integers(min_value=10, max_value=12), min_size=4, max_size=4) + ) if input_shape[2] % 2 != 0: input_shape[2] = input_shape[2] + 1 @@ -112,16 +112,13 @@ def sample_convert_config(self, draw): output_size = draw(st.integers(min_value=1, max_value=3)) elif output_type == "list": output_size = draw( - st.lists( - st.integers( - min_value=1, max_value=3), - min_size=2, - max_size=2)) + st.lists(st.integers(min_value=1, max_value=3), min_size=2, max_size=2) + ) config = { "op_names": ["max_pool2d_with_index"], "test_data_shapes": [input_shape], "test_data_types": [[dtype]], - "opset_version": [7, 9, 15], + "opset_version": [9, 15], "input_spec_shape": [], "output_size": output_size, "data_format": data_format, @@ -131,6 +128,7 @@ def sample_convert_config(self, draw): return (config, models) + @_test_with_pir def test(self): self.run_and_statis(max_examples=30) @@ -145,23 +143,23 @@ def forward(self, inputs): """ forward """ - output_size = self.config['output_size'] + output_size = self.config["output_size"] x = paddle.nn.functional.adaptive_max_pool3d( - inputs, output_size=output_size, return_mask=False) + inputs, output_size=output_size, return_mask=False + ) return x class TestAdaptiveAvgPool3dConvert(OPConvertAutoScanTest): """ api: paddle.nn.functional.adaptive_avg_pool3d - OPset version: 7, 9, 15 + OPset version: 10, 15 """ def sample_convert_config(self, draw): input_shape = draw( - st.lists( - st.integers( - min_value=10, max_value=12), min_size=5, max_size=5)) + st.lists(st.integers(min_value=10, max_value=12), min_size=5, max_size=5) + ) if input_shape[2] % 2 != 0: input_shape[2] = input_shape[2] + 1 @@ -178,17 +176,14 @@ def sample_convert_config(self, draw): output_size = draw(st.integers(min_value=1, max_value=3)) elif output_type == "list": output_size = draw( - st.lists( - st.integers( - min_value=1, max_value=3), - min_size=3, - max_size=3)) + st.lists(st.integers(min_value=1, max_value=3), min_size=3, max_size=3) + ) config = { "op_names": ["max_pool3d_with_index"], "test_data_shapes": [input_shape], "test_data_types": [[dtype]], - "opset_version": [7, 9, 15], + "opset_version": [10, 15], "input_spec_shape": [], "output_size": output_size, "data_format": data_format, @@ -198,6 +193,7 @@ def sample_convert_config(self, draw): return (config, models) + @_test_with_pir def test(self): self.run_and_statis(max_examples=30)