1414# See the License for the specific language governing permissions and
1515# limitations under the License.
1616
17- import itertools
18-
1917import numpy as np
2018import pytest
2119
2220import dpctl .tensor as dpt
2321from dpctl .tests .helper import get_queue_or_skip , skip_if_dtype_not_supported
2422
25- from .utils import _all_dtypes , _usm_types
23+ from .utils import _all_dtypes
2624
2725
2826@pytest .mark .parametrize ("dtype" , _all_dtypes [1 :])
@@ -37,43 +35,3 @@ def test_positive_out_type(dtype):
3735 r = dpt .empty_like (X , dtype = arg_dt )
3836 dpt .positive (X , out = r )
3937 assert np .allclose (dpt .asnumpy (r ), dpt .asnumpy (dpt .positive (X )))
40-
41-
42- @pytest .mark .parametrize ("usm_type" , _usm_types )
43- def test_positive_usm_type (usm_type ):
44- q = get_queue_or_skip ()
45-
46- arg_dt = np .dtype ("i4" )
47- input_shape = (10 , 10 , 10 , 10 )
48- X = dpt .empty (input_shape , dtype = arg_dt , usm_type = usm_type , sycl_queue = q )
49- X [..., 0 ::2 ] = 1
50- X [..., 1 ::2 ] = 0
51-
52- Y = dpt .positive (X )
53- assert Y .usm_type == X .usm_type
54- assert Y .sycl_queue == X .sycl_queue
55- assert Y .flags .c_contiguous
56-
57- expected_Y = dpt .asnumpy (X )
58- assert np .allclose (dpt .asnumpy (Y ), expected_Y )
59-
60-
61- @pytest .mark .parametrize ("dtype" , _all_dtypes [1 :])
62- def test_positive_order (dtype ):
63- q = get_queue_or_skip ()
64- skip_if_dtype_not_supported (dtype , q )
65-
66- arg_dt = np .dtype (dtype )
67- input_shape = (10 , 10 , 10 , 10 )
68- X = dpt .empty (input_shape , dtype = arg_dt , sycl_queue = q )
69- X [..., 0 ::2 ] = 1
70- X [..., 1 ::2 ] = 0
71-
72- for perms in itertools .permutations (range (4 )):
73- U = dpt .permute_dims (X [:, ::- 1 , ::- 1 , :], perms )
74- expected_Y = np .ones (U .shape , dtype = U .dtype )
75- expected_Y [..., 1 ::2 ] = 0
76- expected_Y = np .transpose (expected_Y , perms )
77- for ord in ["C" , "F" , "A" , "K" ]:
78- Y = dpt .positive (U , order = ord )
79- assert np .allclose (dpt .asnumpy (Y ), expected_Y )
0 commit comments