Skip to content

Commit

Permalink
update test_auto_scan_pool_adaptive_max_ops.py
Browse files Browse the repository at this point in the history
  • Loading branch information
zhanghonggeng committed Feb 27, 2025
1 parent 197ddf1 commit b8e3a38
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 35 deletions.
1 change: 0 additions & 1 deletion tests/run.bat
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 0 additions & 1 deletion tests/run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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 \
Expand Down
62 changes: 29 additions & 33 deletions tests/test_auto_scan_pool_adaptive_max_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
Expand All @@ -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
Expand All @@ -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,
}
Expand All @@ -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)

Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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)

Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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)

Expand Down

0 comments on commit b8e3a38

Please sign in to comment.