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

[backport] Add tests for convolve2d #6194

Merged
merged 1 commit into from
Dec 14, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions tests/cupyx_tests/scipy_tests/signal_tests/test_signaltools.py
Original file line number Diff line number Diff line change
Expand Up @@ -209,6 +209,38 @@ def test_correlate2d(self, xp, scp, dtype):
return self._filter('correlate2d', dtype, xp, scp)


@testing.with_requires('scipy')
class TestConvolve2DEdgeCase:

@testing.numpy_cupy_allclose(atol=1e-5, rtol=1e-5, scipy_name='scp')
def test_convolve2d_1(self, xp, scp):
# see cupy/cupy#5989
from scipy import misc
ascent = misc.ascent()
if xp is cupy:
ascent = xp.asarray(ascent)
scharr = xp.array(
[[-3-3j, 0-10j, +3-3j],
[-10+0j, 0+0j, +10+0j],
[-3+3j, 0+10j, +3+3j]]) # Gx + j*Gy
return scp.signal.convolve2d(
ascent, scharr, boundary='symm', mode='same')

@testing.numpy_cupy_allclose(atol=1e-5, rtol=1e-5, scipy_name='scp')
def test_convolve2d_2(self, xp, scp):
# see cupy/cupy#6047
a = xp.array([[257]], dtype="uint64")
b = xp.array([[1]], dtype="uint8")
return scp.signal.convolve2d(a, b, mode="same")

@testing.numpy_cupy_allclose(atol=1e-5, rtol=1e-5, scipy_name='scp')
def test_convolve2d_3(self, xp, scp):
# see cupy/cupy#6047
a = xp.array([[257]], dtype="uint64")
b = xp.array([[1]], dtype="uint8")
return scp.signal.convolve2d(b, a, mode="same")


@testing.gpu
@testing.parameterize(*testing.product({
'mode': ['valid', 'same', 'full']
Expand Down