Skip to content

Commit

Permalink
[BugFix]: Convert tuple to int (#7880)
Browse files Browse the repository at this point in the history
* DEBUG: Convert tuple to int

* Add test cases for test_conv2d_hwcn()

* CI pass
  • Loading branch information
CaptainDuke authored Apr 25, 2021
1 parent ed16f07 commit f92d7fc
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion python/tvm/topi/testing/conv2d_hwcn_python.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,5 +73,5 @@ def conv2d_hwcn_python(a_np, w_np, stride, padding):
else:
apad = at[n, c]
out = scipy.signal.convolve2d(apad, np.rot90(np.rot90(wt[f, c])), mode="valid")
bt[n, f] += out[::stride, ::stride]
bt[n, f] += out[::stride_h, ::stride_w]
return bt.transpose((2, 3, 1, 0))
13 changes: 11 additions & 2 deletions tests/python/topi/python/test_topi_conv2d_hwcn.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,16 +95,25 @@ def check_target(target):

@tvm.testing.requires_gpu
def test_conv2d_hwcn():
verify_conv2d_hwcn(1, 256, 32, 256, 3, 1, "SAME")
verify_conv2d_hwcn(1, 256, 32, 128, 3, 1, "SAME")
verify_conv2d_hwcn(1, 256, 32, 256, 3, 1, "SAME")
verify_conv2d_hwcn(4, 128, 16, 128, 5, 2, "SAME")
verify_conv2d_hwcn(4, 128, 16, 256, 5, 2, "SAME")
verify_conv2d_hwcn(1, 256, 32, 256, 3, 1, "VALID")
verify_conv2d_hwcn(1, 256, 32, 128, 3, 1, "VALID")
verify_conv2d_hwcn(1, 256, 32, 256, 3, 1, "VALID")
verify_conv2d_hwcn(4, 128, 16, 128, 5, 2, "VALID")
verify_conv2d_hwcn(4, 128, 16, 256, 5, 2, "VALID")
# dilation = 2
verify_conv2d_hwcn(1, 256, 32, 256, 3, 1, "SAME", dilation=2)
# Pass stride as tuple
verify_conv2d_hwcn(1, 256, 32, 128, 3, (1, 1), "SAME")
verify_conv2d_hwcn(1, 256, 32, 256, 3, (1, 1), "SAME")
verify_conv2d_hwcn(4, 128, 16, 128, 5, (2, 2), "SAME")
verify_conv2d_hwcn(4, 128, 16, 256, 5, (2, 2), "SAME")
verify_conv2d_hwcn(1, 256, 32, 128, 3, (1, 1), "VALID")
verify_conv2d_hwcn(1, 256, 32, 256, 3, (1, 1), "VALID")
verify_conv2d_hwcn(4, 128, 16, 128, 5, (2, 2), "VALID")
verify_conv2d_hwcn(4, 128, 16, 256, 5, (2, 2), "VALID")


if __name__ == "__main__":
Expand Down

0 comments on commit f92d7fc

Please sign in to comment.