Skip to content

Commit

Permalink
Addition of group > 1 in test and in backend for ConvTranspose (#6175)
Browse files Browse the repository at this point in the history
### Description
Replaces #5877 as the number of impacted files is too high to be
reviewed.

---------

Signed-off-by: Xavier Dupre <xadupre@microsoft.com>
  • Loading branch information
xadupre committed Jun 17, 2024
1 parent 6ec8c87 commit 7934713
Show file tree
Hide file tree
Showing 12 changed files with 459 additions and 6 deletions.
146 changes: 146 additions & 0 deletions docs/Operators.md
Original file line number Diff line number Diff line change
Expand Up @@ -6448,6 +6448,152 @@ expect(node, inputs=[x, W], outputs=[y], name="test_convtranspose_dilations")
</details>


<details>
<summary>convtranspose_group_2</summary>

```python
x = np.array(
[
[
[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]],
[[9.0, 10.0, 11.0], [12.0, 13.0, 14.0], [15.0, 16.0, 17.0]],
]
]
).astype(np.float32)
W = np.array(
[
[
[[1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]],
],
[
[[1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]],
],
]
).astype(np.float32)

node = onnx.helper.make_node("ConvTranspose", ["X", "W"], ["Y"], group=2)

y = np.array(
[
[
[
[0.0, 1.0, 3.0, 3.0, 2.0],
[3.0, 8.0, 15.0, 12.0, 7.0],
[9.0, 21.0, 36.0, 27.0, 15.0],
[9.0, 20.0, 33.0, 24.0, 13.0],
[6.0, 13.0, 21.0, 15.0, 8.0],
],
[
[9.0, 19.0, 30.0, 21.0, 11.0],
[21.0, 44.0, 69.0, 48.0, 25.0],
[36.0, 75.0, 117.0, 81.0, 42.0],
[27.0, 56.0, 87.0, 60.0, 31.0],
[15.0, 31.0, 48.0, 33.0, 17.0],
],
]
]
).astype(np.float32)

expect(node, inputs=[x, W], outputs=[y], name="test_convtranspose_group_2")
```

</details>


<details>
<summary>convtranspose_group_2_image_3</summary>

```python
x = np.array(
[
[
[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]],
[[9.0, 10.0, 11.0], [12.0, 13.0, 14.0], [15.0, 16.0, 17.0]],
],
[
[[18.0, 19.0, 20.0], [21.0, 22.0, 23.0], [24.0, 25.0, 26.0]],
[[9.0, 10.0, 11.0], [12.0, 13.0, 14.0], [15.0, 16.0, 17.0]],
],
[
[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]],
[[9.0, 10.0, 11.0], [12.0, 13.0, 14.0], [15.0, 16.0, 17.0]],
],
]
).astype(np.float32)
W = np.array(
[
[
[[1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]],
],
[
[[1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]],
],
]
).astype(np.float32)

node = onnx.helper.make_node("ConvTranspose", ["X", "W"], ["Y"], group=2)

y = np.array(
[
[
[
[0.0, 1.0, 3.0, 3.0, 2.0],
[3.0, 8.0, 15.0, 12.0, 7.0],
[9.0, 21.0, 36.0, 27.0, 15.0],
[9.0, 20.0, 33.0, 24.0, 13.0],
[6.0, 13.0, 21.0, 15.0, 8.0],
],
[
[9.0, 19.0, 30.0, 21.0, 11.0],
[21.0, 44.0, 69.0, 48.0, 25.0],
[36.0, 75.0, 117.0, 81.0, 42.0],
[27.0, 56.0, 87.0, 60.0, 31.0],
[15.0, 31.0, 48.0, 33.0, 17.0],
],
],
[
[
[18.0, 37.0, 57.0, 39.0, 20.0],
[39.0, 80.0, 123.0, 84.0, 43.0],
[63.0, 129.0, 198.0, 135.0, 69.0],
[45.0, 92.0, 141.0, 96.0, 49.0],
[24.0, 49.0, 75.0, 51.0, 26.0],
],
[
[9.0, 19.0, 30.0, 21.0, 11.0],
[21.0, 44.0, 69.0, 48.0, 25.0],
[36.0, 75.0, 117.0, 81.0, 42.0],
[27.0, 56.0, 87.0, 60.0, 31.0],
[15.0, 31.0, 48.0, 33.0, 17.0],
],
],
[
[
[0.0, 1.0, 3.0, 3.0, 2.0],
[3.0, 8.0, 15.0, 12.0, 7.0],
[9.0, 21.0, 36.0, 27.0, 15.0],
[9.0, 20.0, 33.0, 24.0, 13.0],
[6.0, 13.0, 21.0, 15.0, 8.0],
],
[
[9.0, 19.0, 30.0, 21.0, 11.0],
[21.0, 44.0, 69.0, 48.0, 25.0],
[36.0, 75.0, 117.0, 81.0, 42.0],
[27.0, 56.0, 87.0, 60.0, 31.0],
[15.0, 31.0, 48.0, 33.0, 17.0],
],
],
]
).astype(np.float32)

expect(
node, inputs=[x, W], outputs=[y], name="test_convtranspose_group_2_image_3"
)
```

</details>


<details>
<summary>convtranspose_pads</summary>

Expand Down
144 changes: 143 additions & 1 deletion docs/TestCoverage.md
Original file line number Diff line number Diff line change
Expand Up @@ -4236,7 +4236,7 @@ expect(


### ConvTranspose
There are 7 test cases, listed as following:
There are 9 test cases, listed as following:
<details>
<summary>convtranspose</summary>

Expand Down Expand Up @@ -4600,6 +4600,148 @@ y = np.array(
expect(node, inputs=[x, W], outputs=[y], name="test_convtranspose_dilations")
```

</details>
<details>
<summary>convtranspose_group_2</summary>

```python
x = np.array(
[
[
[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]],
[[9.0, 10.0, 11.0], [12.0, 13.0, 14.0], [15.0, 16.0, 17.0]],
]
]
).astype(np.float32)
W = np.array(
[
[
[[1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]],
],
[
[[1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]],
],
]
).astype(np.float32)

node = onnx.helper.make_node("ConvTranspose", ["X", "W"], ["Y"], group=2)

y = np.array(
[
[
[
[0.0, 1.0, 3.0, 3.0, 2.0],
[3.0, 8.0, 15.0, 12.0, 7.0],
[9.0, 21.0, 36.0, 27.0, 15.0],
[9.0, 20.0, 33.0, 24.0, 13.0],
[6.0, 13.0, 21.0, 15.0, 8.0],
],
[
[9.0, 19.0, 30.0, 21.0, 11.0],
[21.0, 44.0, 69.0, 48.0, 25.0],
[36.0, 75.0, 117.0, 81.0, 42.0],
[27.0, 56.0, 87.0, 60.0, 31.0],
[15.0, 31.0, 48.0, 33.0, 17.0],
],
]
]
).astype(np.float32)

expect(node, inputs=[x, W], outputs=[y], name="test_convtranspose_group_2")
```

</details>
<details>
<summary>convtranspose_group_2_image_3</summary>

```python
x = np.array(
[
[
[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]],
[[9.0, 10.0, 11.0], [12.0, 13.0, 14.0], [15.0, 16.0, 17.0]],
],
[
[[18.0, 19.0, 20.0], [21.0, 22.0, 23.0], [24.0, 25.0, 26.0]],
[[9.0, 10.0, 11.0], [12.0, 13.0, 14.0], [15.0, 16.0, 17.0]],
],
[
[[0.0, 1.0, 2.0], [3.0, 4.0, 5.0], [6.0, 7.0, 8.0]],
[[9.0, 10.0, 11.0], [12.0, 13.0, 14.0], [15.0, 16.0, 17.0]],
],
]
).astype(np.float32)
W = np.array(
[
[
[[1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]],
],
[
[[1.0, 1.0, 1.0], [1.0, 1.0, 1.0], [1.0, 1.0, 1.0]],
],
]
).astype(np.float32)

node = onnx.helper.make_node("ConvTranspose", ["X", "W"], ["Y"], group=2)

y = np.array(
[
[
[
[0.0, 1.0, 3.0, 3.0, 2.0],
[3.0, 8.0, 15.0, 12.0, 7.0],
[9.0, 21.0, 36.0, 27.0, 15.0],
[9.0, 20.0, 33.0, 24.0, 13.0],
[6.0, 13.0, 21.0, 15.0, 8.0],
],
[
[9.0, 19.0, 30.0, 21.0, 11.0],
[21.0, 44.0, 69.0, 48.0, 25.0],
[36.0, 75.0, 117.0, 81.0, 42.0],
[27.0, 56.0, 87.0, 60.0, 31.0],
[15.0, 31.0, 48.0, 33.0, 17.0],
],
],
[
[
[18.0, 37.0, 57.0, 39.0, 20.0],
[39.0, 80.0, 123.0, 84.0, 43.0],
[63.0, 129.0, 198.0, 135.0, 69.0],
[45.0, 92.0, 141.0, 96.0, 49.0],
[24.0, 49.0, 75.0, 51.0, 26.0],
],
[
[9.0, 19.0, 30.0, 21.0, 11.0],
[21.0, 44.0, 69.0, 48.0, 25.0],
[36.0, 75.0, 117.0, 81.0, 42.0],
[27.0, 56.0, 87.0, 60.0, 31.0],
[15.0, 31.0, 48.0, 33.0, 17.0],
],
],
[
[
[0.0, 1.0, 3.0, 3.0, 2.0],
[3.0, 8.0, 15.0, 12.0, 7.0],
[9.0, 21.0, 36.0, 27.0, 15.0],
[9.0, 20.0, 33.0, 24.0, 13.0],
[6.0, 13.0, 21.0, 15.0, 8.0],
],
[
[9.0, 19.0, 30.0, 21.0, 11.0],
[21.0, 44.0, 69.0, 48.0, 25.0],
[36.0, 75.0, 117.0, 81.0, 42.0],
[27.0, 56.0, 87.0, 60.0, 31.0],
[15.0, 31.0, 48.0, 33.0, 17.0],
],
],
]
).astype(np.float32)

expect(
node, inputs=[x, W], outputs=[y], name="test_convtranspose_group_2_image_3"
)
```

</details>
<details>
<summary>convtranspose_pads</summary>
Expand Down
Loading

0 comments on commit 7934713

Please sign in to comment.