示例#1
0
文件: test_cuda.py 项目: y1r/chainer
    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)
示例#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)
示例#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)))
示例#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
示例#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
示例#6
0
 def test_array_gpu(self):
     self._check_array(cuda.ndarray([1, 2]), 'constant array')
示例#7
0
 def test_array_gpu(self):
     self._check_array(cuda.ndarray([1, 2]), 'constant array')