Beispiel #1
0
    def test_to_and_from_gpu(self):
        """ Make sure we can load and unload data off the gpu. """
        shape = (100,100,100)
        d = Data()
        space.initialize_space(shape)

        for dtype in self.valid_dtypes:
            # Create data to load.
            d_cpu = np.random.randn(*shape).astype(dtype)
            if dtype in (np.complex64, np.complex128):
                d_cpu = (1 + 1j) * d_cpu

            # Load and retrieve.
            d.to_gpu(d_cpu)
            self.assertTrue((d_cpu == d.get()).all())