def test_coherence_complex(num_samps, fs, nperseg):
    cpu_x = np.random.rand(num_samps) + 1j * np.random.rand(num_samps)
    cpu_y = np.random.rand(num_samps) + 1j * np.random.rand(num_samps)
    gpu_x = cp.asarray(cpu_x)
    gpu_y = cp.asarray(cpu_y)

    cf, cpu_coherence = signal.coherence(cpu_x, cpu_y, fs, nperseg=nperseg)
    gf, gpu_coherence = cusignal.coherence(gpu_x, gpu_y, fs, nperseg=nperseg)
    gpu_coherence = cp.asnumpy(gpu_coherence)

    assert array_equal(cpu_coherence, gpu_coherence)
Exemple #2
0
    def test_coherence(self, rand_data_gen, num_samps, fs, nperseg):
        cpu_x, gpu_x = rand_data_gen(num_samps)
        cpu_y, gpu_y = rand_data_gen(num_samps)

        _, cpu_coherence = signal.coherence(cpu_x, cpu_y, fs, nperseg=nperseg)
        _, gpu_coherence = cusignal.coherence(gpu_x,
                                              gpu_y,
                                              fs,
                                              nperseg=nperseg)
        gpu_coherence = cp.asnumpy(gpu_coherence)

        assert array_equal(cpu_coherence, gpu_coherence)
Exemple #3
0
 def gpu_version(self, x, y, fs, nperseg):
     with cp.cuda.Stream.null:
         out = cusignal.coherence(x, y, fs, nperseg=nperseg)
     cp.cuda.Stream.null.synchronize()
     return out