def gpu_version(self, sig, filt, boundary, mode): with cp.cuda.Stream.null: out = cusignal.convolve2d(sig, filt, boundary=boundary, mode=mode) cp.cuda.Stream.null.synchronize() return out
def test_convolve2d(num_samps, num_taps, boundary, mode): cpu_sig = np.random.rand(num_samps, num_samps) cpu_filt = np.random.rand(num_taps, num_taps) gpu_sig = cp.asarray(cpu_sig) gpu_filt = cp.asarray(cpu_filt) cpu_convolve2d = signal.convolve2d( cpu_sig, cpu_filt, boundary=boundary, mode=mode ) gpu_convolve2d = cp.asnumpy( cusignal.convolve2d(gpu_sig, gpu_filt, boundary=boundary, mode=mode) ) assert array_equal(cpu_convolve2d, gpu_convolve2d)