Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dilation case for ConvTranspose op #1797

Merged
merged 9 commits into from Feb 11, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
24 changes: 24 additions & 0 deletions docs/Operators.md
Expand Up @@ -2687,6 +2687,30 @@ expect(node, inputs=[x, W], outputs=[y],
</details>


<details>
<summary>convtranspose_dilations</summary>

```python
x = np.array([[[[3., 8., 1.], # (1, 1, 3, 3)
[9., 5., 7.],
[3., 2., 6.]]]]).astype(np.float32)
W = np.array([[[[7., 2.], # (1, 1, 2, 2)
[1., 9.]]]]).astype(np.float32)

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

y = np.array([[[[21., 56., 13., 16., 2.], # [1, 1, 5, 5]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I checked, the results I got was:

tensor([[[[21.1887, 56.1887, 13.1887, 16.1887, 2.1887],
[63.1887, 35.1887, 67.1887, 10.1887, 14.1887],
[24.1887, 22.1887, 76.1887, 76.1887, 21.1887],
[ 9.1887, 5.1887, 88.1887, 45.1887, 63.1887],
[ 3.1887, 2.1887, 33.1887, 18.1887, 54.1887]]]]

Did I miss something here?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Mind to share your script here?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Never mind, I forgot to set bias. Apparently, that noise is from bias.

The result look good to me now.

[63., 35., 67., 10., 14.],
[24., 22., 76., 76., 21.],
[9., 5., 88., 45., 63.],
[3., 2., 33., 18., 54.]]]]).astype(np.float32)

expect(node, inputs=[x, W], outputs=[y], name='test_convtranspose_dilations')
```

</details>


<details>
<summary>convtranspose_pads</summary>

Expand Down
24 changes: 23 additions & 1 deletion docs/TestCoverage.md
Expand Up @@ -1345,7 +1345,7 @@ expect(node_with_asymmetric_padding, inputs=[x, W], outputs=[y_with_asymmetric_p


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

Expand Down Expand Up @@ -1568,6 +1568,28 @@ expect(node, inputs=[x, W], outputs=[y],
name='test_convtranspose_kernel_shape')
```

</details>
<details>
<summary>convtranspose_dilations</summary>

```python
x = np.array([[[[3., 8., 1.], # (1, 1, 3, 3)
[9., 5., 7.],
[3., 2., 6.]]]]).astype(np.float32)
W = np.array([[[[7., 2.], # (1, 1, 2, 2)
[1., 9.]]]]).astype(np.float32)

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

y = np.array([[[[21., 56., 13., 16., 2.], # [1, 1, 5, 5]
[63., 35., 67., 10., 14.],
[24., 22., 76., 76., 21.],
[9., 5., 88., 45., 63.],
[3., 2., 33., 18., 54.]]]]).astype(np.float32)

expect(node, inputs=[x, W], outputs=[y], name='test_convtranspose_dilations')
```

</details>
<details>
<summary>convtranspose_pads</summary>
Expand Down
18 changes: 18 additions & 0 deletions onnx/backend/test/case/node/convtranspose.py
Expand Up @@ -253,3 +253,21 @@ def export_convtranspose_pads(): # type: () -> None
[13., 7., 15.]]]]).astype(np.float32)

expect(node, inputs=[x, W], outputs=[y], name='test_convtranspose_pads')

@staticmethod
def export_convtranspose_dilations(): # type: () -> None
x = np.array([[[[3., 8., 1.], # (1, 1, 3, 3)
[9., 5., 7.],
[3., 2., 6.]]]]).astype(np.float32)
W = np.array([[[[7., 2.], # (1, 1, 2, 2)
[1., 9.]]]]).astype(np.float32)

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

y = np.array([[[[21., 56., 13., 16., 2.], # [1, 1, 5, 5]
[63., 35., 67., 10., 14.],
[24., 22., 76., 76., 21.],
[9., 5., 88., 45., 63.],
[3., 2., 33., 18., 54.]]]]).astype(np.float32)

expect(node, inputs=[x, W], outputs=[y], name='test_convtranspose_dilations')
@@ -0,0 +1,23 @@
 backend-test:�
,
X
WY"ConvTranspose*
dilations@@�test_convtranspose_dilationsZ
X




Z
W




b
Y




B
Expand Down
Binary file not shown.
Binary file not shown.
Binary file not shown.