Skip to content

Commit abb4457

Browse files
authored
Add missing ReduceMax's empty set test (onnx#5684)
### Description <!-- - Describe your changes. --> Adds missing ReduceMax test with empty set ### Motivation and Context <!-- - Why is this change required? What problem does it solve? --> <!-- - If it fixes an open issue, please link to the issue here. --> There is test for ReduceMin but for ReduceMax seems to be missing in onnx#5568 --------- Signed-off-by: twata <[email protected]>
1 parent 9bf7833 commit abb4457

File tree

3 files changed

+89
-1
lines changed

3 files changed

+89
-1
lines changed

docs/Operators.md

+32
Original file line numberDiff line numberDiff line change
@@ -21869,6 +21869,38 @@ expect(
2186921869
</details>
2187021870

2187121871

21872+
<details>
21873+
<summary>empty_set</summary>
21874+
21875+
```python
21876+
shape = [2, 0, 4]
21877+
keepdims = 1
21878+
reduced_shape = [2, 1, 4]
21879+
21880+
node = onnx.helper.make_node(
21881+
"ReduceMax",
21882+
inputs=["data", "axes"],
21883+
outputs=["reduced"],
21884+
keepdims=keepdims,
21885+
)
21886+
21887+
data = np.array([], dtype=np.float32).reshape(shape)
21888+
axes = np.array([1], dtype=np.int64)
21889+
one = np.array(np.ones(reduced_shape, dtype=np.float32))
21890+
zero = np.array(np.zeros(reduced_shape, dtype=np.float32))
21891+
reduced = -(one / zero) # -inf
21892+
21893+
expect(
21894+
node,
21895+
inputs=[data, axes],
21896+
outputs=[reduced],
21897+
name="test_reduce_min_empty_set",
21898+
)
21899+
```
21900+
21901+
</details>
21902+
21903+
2187221904
<details>
2187321905
<summary>keepdims</summary>
2187421906

docs/TestCoverage.md

+31-1
Original file line numberDiff line numberDiff line change
@@ -14574,7 +14574,7 @@ expect(
1457414574

1457514575

1457614576
### ReduceMax
14577-
There are 5 test cases, listed as following:
14577+
There are 6 test cases, listed as following:
1457814578
<details>
1457914579
<summary>bool_inputs</summary>
1458014580

@@ -14693,6 +14693,36 @@ expect(
1469314693
)
1469414694
```
1469514695

14696+
</details>
14697+
<details>
14698+
<summary>empty_set</summary>
14699+
14700+
```python
14701+
shape = [2, 0, 4]
14702+
keepdims = 1
14703+
reduced_shape = [2, 1, 4]
14704+
14705+
node = onnx.helper.make_node(
14706+
"ReduceMax",
14707+
inputs=["data", "axes"],
14708+
outputs=["reduced"],
14709+
keepdims=keepdims,
14710+
)
14711+
14712+
data = np.array([], dtype=np.float32).reshape(shape)
14713+
axes = np.array([1], dtype=np.int64)
14714+
one = np.array(np.ones(reduced_shape, dtype=np.float32))
14715+
zero = np.array(np.zeros(reduced_shape, dtype=np.float32))
14716+
reduced = -(one / zero) # -inf
14717+
14718+
expect(
14719+
node,
14720+
inputs=[data, axes],
14721+
outputs=[reduced],
14722+
name="test_reduce_min_empty_set",
14723+
)
14724+
```
14725+
1469614726
</details>
1469714727
<details>
1469814728
<summary>keepdims</summary>

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

+26
Original file line numberDiff line numberDiff line change
@@ -202,3 +202,29 @@ def export_bool_inputs() -> None:
202202
outputs=[reduced],
203203
name="test_reduce_max_bool_inputs",
204204
)
205+
206+
@staticmethod
207+
def export_empty_set() -> None:
208+
shape = [2, 0, 4]
209+
keepdims = 1
210+
reduced_shape = [2, 1, 4]
211+
212+
node = onnx.helper.make_node(
213+
"ReduceMax",
214+
inputs=["data", "axes"],
215+
outputs=["reduced"],
216+
keepdims=keepdims,
217+
)
218+
219+
data = np.array([], dtype=np.float32).reshape(shape)
220+
axes = np.array([1], dtype=np.int64)
221+
one = np.array(np.ones(reduced_shape, dtype=np.float32))
222+
zero = np.array(np.zeros(reduced_shape, dtype=np.float32))
223+
reduced = -(one / zero) # -inf
224+
225+
expect(
226+
node,
227+
inputs=[data, axes],
228+
outputs=[reduced],
229+
name="test_reduce_min_empty_set",
230+
)

0 commit comments

Comments
 (0)