def test_from_array(self, backend_config): with cuda.Device(backend_config.cuda_device): arr = cuda.ndarray((), numpy.float32) # Test precondition check assert arr.device.id == backend_config.cuda_device device = backend.GpuDevice.from_array(arr) self.check_device(device, backend_config) assert device == backend.GpuDevice.from_device_id( backend_config.cuda_device)
def test_from_array(self, backend_config): with cuda.Device(backend_config.cuda_device): arr = cuda.ndarray((), numpy.float32) # Test precondition check assert arr.device.id == backend_config.cuda_device device = backend.GpuDevice.from_array(arr) assert isinstance(device, backend.GpuDevice) assert device == backend.GpuDevice.from_device_id( backend_config.cuda_device)
def test_from_array(self, backend_config): with cuda.Device(backend_config.cuda_device): arr = cuda.ndarray((), numpy.float32) # Test precondition check assert arr.device.id == backend_config.cuda_device device = backend.GpuDevice.from_array(arr) assert isinstance(device, backend.GpuDevice) assert (device == chainer.get_device((cuda.cupy, backend_config.cuda_device)))
def test_get_device_from_array(self, backend_config): with cuda.Device(backend_config.cuda_device): arr = cuda.ndarray((), numpy.float32) # Test precondition check assert arr.device.id == backend_config.cuda_device expected_device = backend_config.device device = backend.GpuDevice.from_array(arr) assert device == expected_device device = backend.get_device_from_array(arr) assert device == expected_device
def test_array_gpu(self): self._check_array(cuda.ndarray([1, 2]), 'constant array')