diff --git a/dpnp/dpnp_array.py b/dpnp/dpnp_array.py index 5aaf3c6efbda..c0bd122aea18 100644 --- a/dpnp/dpnp_array.py +++ b/dpnp/dpnp_array.py @@ -97,6 +97,13 @@ def T(self): else: return dpnp.transpose(self) + def to_device(self, target_device): + """ + Transfer array to target device + """ + + return dpnp_array(shape=self.shape, buffer=self.get_array().to_device(target_device)) + def __abs__(self): return dpnp.abs(self) diff --git a/tests/test_sycl_queue.py b/tests/test_sycl_queue.py index 66fbfb786f89..d3cf85d88b74 100644 --- a/tests/test_sycl_queue.py +++ b/tests/test_sycl_queue.py @@ -83,3 +83,18 @@ def test_2in_1out(func, device): assert_sycl_queue_equal(result_queue, expected_queue) assert result_queue.sycl_device == expected_queue.sycl_device + + +@pytest.mark.parametrize("device_from", + valid_devices, + ids=[device.filter_string for device in valid_devices]) +@pytest.mark.parametrize("device_to", + valid_devices, + ids=[device.filter_string for device in valid_devices]) +def test_to_device(device_from, device_to): + data = [1., 1., 1., 1., 1.] + + x = dpnp.array(data, device=device_from) + y = x.to_device(device_to) + + assert y.get_array().sycl_device == device_to