Beispiel #1
0
 def test_copy_multi_device_non_contiguous(self, order):
     arr = core.ndarray((20,))[::2]
     dev1 = cuda.Device(1)
     with dev1:
         arr2 = arr.copy(order)
     assert arr2.device == dev1
     testing.assert_array_equal(arr, arr2)
Beispiel #2
0
 def test_order(self):
     shape = (2, 3, 4)
     a = core.ndarray(shape, order='F')
     a_cpu = numpy.ndarray(shape, order='F')
     assert a.strides == a_cpu.strides
     assert a.flags.f_contiguous
     assert not a.flags.c_contiguous
Beispiel #3
0
def _convert_object_with_cuda_array_interface(a):
    desc = a.__cuda_array_interface__
    shape = desc['shape']
    dtype = numpy.dtype(desc['typestr'])
    if 'strides' in desc:
        strides = desc['strides']
        nbytes = numpy.max(numpy.array(shape) * numpy.array(strides))
    else:
        strides = None
        nbytes = numpy.prod(shape) * dtype.itemsize
    mem = memory.UnownedMemory(desc['data'][0], nbytes, a)
    memptr = memory.MemoryPointer(mem, 0)
    return ndarray(shape, dtype=dtype, memptr=memptr, strides=strides)
Beispiel #4
0
 def test_copy_multi_device_non_contiguous_K(self):
     arr = core.ndarray((20,))[::2]
     with cuda.Device(1):
         with self.assertRaises(NotImplementedError):
             arr.copy('K')
Beispiel #5
0
 def test_deepcopy_multi_device(self):
     arr = core.ndarray(self.shape)
     with cuda.Device(1):
         arr2 = copy.deepcopy(arr)
     self._check_deepcopy(arr, arr2)
     assert arr2.device == arr.device
Beispiel #6
0
 def test_deepcopy(self):
     arr = core.ndarray(self.shape)
     arr2 = copy.deepcopy(arr)
     self._check_deepcopy(arr, arr2)
Beispiel #7
0
 def test_order_none(self):
     a = core.ndarray(self.shape, order=None)
     a_cpu = numpy.ndarray(self.shape, order=None)
     self.assertEqual(a.flags.c_contiguous, a_cpu.flags.c_contiguous)
     self.assertEqual(a.flags.f_contiguous, a_cpu.flags.f_contiguous)
     self.assertTupleEqual(a.strides, a_cpu.strides)
Beispiel #8
0
 def test_order(self):
     a = core.ndarray(self.shape, order='F')
     a_cpu = numpy.ndarray(self.shape, order='F')
     self.assertTupleEqual(a.strides, a_cpu.strides)
     self.assertTrue(a.flags.f_contiguous)
     self.assertTrue(not a.flags.c_contiguous)
Beispiel #9
0
 def test_shape(self):
     a = core.ndarray(self.arg)
     self.assertTupleEqual(a.shape, self.shape)
Beispiel #10
0
 def setUp(self):
     self.a = core.ndarray(())
Beispiel #11
0
 def test_shape(self):
     a = core.ndarray(self.arg)
     self.assertTupleEqual(a.shape, self.shape)
 def setUp(self):
     self.a = core.ndarray(())
Beispiel #13
0
 def test_order(self):
     a = core.ndarray(self.shape, order='F')
     a_cpu = numpy.ndarray(self.shape, order='F')
     self.assertTupleEqual(a.strides, a_cpu.strides)
     self.assertTrue(a.flags.f_contiguous)
     self.assertTrue(not a.flags.c_contiguous)