def gpu_version(self, sig, filt, boundary, mode): with cp.cuda.Stream.null: out = cusignal.correlate2d(sig, filt, boundary=boundary, mode=mode) cp.cuda.Stream.null.synchronize() return out
def test_correlate2d(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_correlate2d = signal.correlate2d( cpu_sig, cpu_filt, boundary=boundary, mode=mode ) gpu_correlate2d = cp.asnumpy( cusignal.correlate2d(gpu_sig, gpu_filt, boundary=boundary, mode=mode) ) assert array_equal(cpu_correlate2d, gpu_correlate2d)
def test_correlate2d(self, rand_2d_data_gen, num_samps, num_taps, boundary, mode, use_numba): cpu_sig, gpu_sig = rand_2d_data_gen(num_samps) cpu_filt, gpu_filt = rand_2d_data_gen(num_taps) cpu_correlate2d = signal.correlate2d(cpu_sig, cpu_filt, boundary=boundary, mode=mode) gpu_correlate2d = cp.asnumpy( cusignal.correlate2d( gpu_sig, gpu_filt, boundary=boundary, mode=mode, use_numba=use_numba, )) assert array_equal(cpu_correlate2d, gpu_correlate2d)