Skip to content

Commit 280cd3c

Browse files
committed
add a new test
Signed-off-by: titaiwangms <titaiwang@microsoft.com>
1 parent 46322c1 commit 280cd3c

File tree

6 files changed

+109
-1
lines changed

6 files changed

+109
-1
lines changed

docs/Operators.md

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1769,6 +1769,44 @@ expect(node, inputs=[x], outputs=[y], name="test_averagepool_2d_ceil")
17691769
</details>
17701770

17711771

1772+
<details>
1773+
<summary>averagepool_2d_ceil_last_window_starts_on_pad</summary>
1774+
1775+
```python
1776+
"""input_shape: [1, 3, 2, 2]
1777+
output_shape: [1, 3, 1, 1]
1778+
"""
1779+
node = onnx.helper.make_node(
1780+
"AveragePool",
1781+
inputs=["x"],
1782+
outputs=["y"],
1783+
kernel_shape=[3, 3],
1784+
strides=[3, 3],
1785+
pads=[1, 1, 1, 1],
1786+
ceil_mode=True,
1787+
)
1788+
x = np.array(
1789+
[
1790+
[
1791+
[[0.8580, 0.0786], [0.2692, 0.1537]],
1792+
[[0.8816, 0.4353], [0.5772, 0.6623]],
1793+
[[0.9067, 0.9483], [0.5970, 0.7630]],
1794+
]
1795+
]
1796+
).astype(np.float32)
1797+
y = np.array([[[[0.1511]], [[0.2841]], [[0.3572]]]]).astype(np.float32)
1798+
1799+
expect(
1800+
node,
1801+
inputs=[x],
1802+
outputs=[y],
1803+
name="test_averagepool_2d_ceil_last_window_starts_on_pad",
1804+
)
1805+
```
1806+
1807+
</details>
1808+
1809+
17721810
<details>
17731811
<summary>averagepool_2d_default</summary>
17741812

docs/TestCoverage.md

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1105,7 +1105,7 @@ expect(node, inputs=[x], outputs=[y], name="test_atanh")
11051105

11061106

11071107
### AveragePool
1108-
There are 16 test cases, listed as following:
1108+
There are 17 test cases, listed as following:
11091109
<details>
11101110
<summary>averagepool_1d_default</summary>
11111111

@@ -1166,6 +1166,42 @@ y = np.array([[[[6, 7.5], [12, 13.5]]]]).astype(np.float32)
11661166
expect(node, inputs=[x], outputs=[y], name="test_averagepool_2d_ceil")
11671167
```
11681168

1169+
</details>
1170+
<details>
1171+
<summary>averagepool_2d_ceil_last_window_starts_on_pad</summary>
1172+
1173+
```python
1174+
"""input_shape: [1, 3, 2, 2]
1175+
output_shape: [1, 3, 1, 1]
1176+
"""
1177+
node = onnx.helper.make_node(
1178+
"AveragePool",
1179+
inputs=["x"],
1180+
outputs=["y"],
1181+
kernel_shape=[3, 3],
1182+
strides=[3, 3],
1183+
pads=[1, 1, 1, 1],
1184+
ceil_mode=True,
1185+
)
1186+
x = np.array(
1187+
[
1188+
[
1189+
[[0.8580, 0.0786], [0.2692, 0.1537]],
1190+
[[0.8816, 0.4353], [0.5772, 0.6623]],
1191+
[[0.9067, 0.9483], [0.5970, 0.7630]],
1192+
]
1193+
]
1194+
).astype(np.float32)
1195+
y = np.array([[[[0.1511]], [[0.2841]], [[0.3572]]]]).astype(np.float32)
1196+
1197+
expect(
1198+
node,
1199+
inputs=[x],
1200+
outputs=[y],
1201+
name="test_averagepool_2d_ceil_last_window_starts_on_pad",
1202+
)
1203+
```
1204+
11691205
</details>
11701206
<details>
11711207
<summary>averagepool_2d_default</summary>

onnx/backend/test/case/node/averagepool.py

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -515,6 +515,38 @@ def export_averagepool_2d_ceil() -> None:
515515

516516
expect(node, inputs=[x], outputs=[y], name="test_averagepool_2d_ceil")
517517

518+
@staticmethod
519+
def export_averagepool_2d_ceil_last_window_starts_on_pad() -> None:
520+
"""input_shape: [1, 3, 2, 2]
521+
output_shape: [1, 3, 1, 1]
522+
"""
523+
node = onnx.helper.make_node(
524+
"AveragePool",
525+
inputs=["x"],
526+
outputs=["y"],
527+
kernel_shape=[3, 3],
528+
strides=[3, 3],
529+
pads=[1, 1, 1, 1],
530+
ceil_mode=True,
531+
)
532+
x = np.array(
533+
[
534+
[
535+
[[0.8580, 0.0786], [0.2692, 0.1537]],
536+
[[0.8816, 0.4353], [0.5772, 0.6623]],
537+
[[0.9067, 0.9483], [0.5970, 0.7630]],
538+
]
539+
]
540+
).astype(np.float32)
541+
y = np.array([[[[0.1511]], [[0.2841]], [[0.3572]]]]).astype(np.float32)
542+
543+
expect(
544+
node,
545+
inputs=[x],
546+
outputs=[y],
547+
name="test_averagepool_2d_ceil_last_window_starts_on_pad",
548+
)
549+
518550
@staticmethod
519551
def export_averagepool_2d_dilations() -> None:
520552
"""input_shape: [1, 1, 4, 4]
Binary file not shown.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
BxJ0�[? ��=�ԉ>�c>��a?���>a�?~�)?~h?��r?��?�SC?
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
ByJ ��>�u�>��>

0 commit comments

Comments
 (0)