@@ -1949,12 +1949,14 @@ def test_basic(self, device_from, device_to):
1949
1949
1950
1950
y = x .to_device (device_to )
1951
1951
assert y .sycl_device == device_to
1952
+ assert (x .asnumpy () == y .asnumpy ()).all ()
1952
1953
1953
1954
def test_to_queue (self ):
1954
1955
x = dpnp .full (100 , 2 , dtype = dpnp .int64 )
1955
1956
q_prof = dpctl .SyclQueue (x .sycl_device , property = "enable_profiling" )
1956
1957
1957
1958
y = x .to_device (q_prof )
1959
+ assert (x .asnumpy () == y .asnumpy ()).all ()
1958
1960
assert_sycl_queue_equal (y .sycl_queue , q_prof )
1959
1961
1960
1962
def test_stream (self ):
@@ -1963,21 +1965,34 @@ def test_stream(self):
1963
1965
q_exec = dpctl .SyclQueue (x .sycl_device )
1964
1966
1965
1967
y = x .to_device (q_prof , stream = q_exec )
1968
+ assert (x .asnumpy () == y .asnumpy ()).all ()
1966
1969
assert_sycl_queue_equal (y .sycl_queue , q_prof )
1967
1970
1968
1971
q_exec = dpctl .SyclQueue (x .sycl_device )
1969
1972
_ = dpnp .linspace (0 , 20 , num = 10 ** 5 , sycl_queue = q_exec )
1970
1973
y = x .to_device (q_prof , stream = q_exec )
1974
+ assert (x .asnumpy () == y .asnumpy ()).all ()
1971
1975
assert_sycl_queue_equal (y .sycl_queue , q_prof )
1972
1976
1973
1977
def test_stream_no_sync (self ):
1974
1978
x = dpnp .full (100 , 2 , dtype = dpnp .int64 )
1975
1979
q_prof = dpctl .SyclQueue (x .sycl_device , property = "enable_profiling" )
1976
1980
1977
- for stream in [None , 1 , dpctl . SyclDevice (), x .sycl_queue ]:
1981
+ for stream in [None , x .sycl_queue ]:
1978
1982
y = x .to_device (q_prof , stream = stream )
1983
+ assert (x .asnumpy () == y .asnumpy ()).all ()
1979
1984
assert_sycl_queue_equal (y .sycl_queue , q_prof )
1980
1985
1986
+ @pytest .mark .parametrize (
1987
+ "stream" ,
1988
+ [1 , dict (), dpctl .SyclDevice ()],
1989
+ ids = ["scalar" , "dictionary" , "device" ],
1990
+ )
1991
+ def test_invalid_stream (self , stream ):
1992
+ x = dpnp .ones (2 , dtype = dpnp .int64 )
1993
+ q_prof = dpctl .SyclQueue (x .sycl_device , property = "enable_profiling" )
1994
+ assert_raises (TypeError , x .to_device , q_prof , stream = stream )
1995
+
1981
1996
1982
1997
@pytest .mark .parametrize (
1983
1998
"device" ,
0 commit comments