Esempio n. 1
0
    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)
Esempio n. 2
0
    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)
Esempio n. 3
0
    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)))
Esempio n. 4
0
    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
Esempio n. 5
0
    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
Esempio n. 6
0
 def test_array_gpu(self):
     self._check_array(cuda.ndarray([1, 2]), 'constant array')
Esempio n. 7
0
 def test_array_gpu(self):
     self._check_array(cuda.ndarray([1, 2]), 'constant array')