Skip to content

Commit 85ea6f9

Browse files
authored
Merge pull request #1498 from IntelPython/iris_xe_test1
Update tests to run on Iris Xe
2 parents 713302a + f510e16 commit 85ea6f9

File tree

7 files changed

+148
-71
lines changed

7 files changed

+148
-71
lines changed

dpnp/backend/kernels/dpnp_krnl_random.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2988,9 +2988,13 @@ void func_map_init_random(func_map_t &fmap)
29882988

29892989
fmap[DPNPFuncName::DPNP_FN_RNG_CHISQUARE][eft_DBL][eft_DBL] = {
29902990
eft_DBL, (void *)dpnp_rng_chisquare_default_c<double>};
2991+
fmap[DPNPFuncName::DPNP_FN_RNG_CHISQUARE][eft_FLT][eft_FLT] = {
2992+
eft_FLT, (void *)dpnp_rng_chisquare_default_c<float>};
29912993

29922994
fmap[DPNPFuncName::DPNP_FN_RNG_CHISQUARE_EXT][eft_DBL][eft_DBL] = {
29932995
eft_DBL, (void *)dpnp_rng_chisquare_ext_c<double>};
2996+
fmap[DPNPFuncName::DPNP_FN_RNG_CHISQUARE_EXT][eft_FLT][eft_FLT] = {
2997+
eft_FLT, (void *)dpnp_rng_chisquare_ext_c<float>};
29942998

29952999
fmap[DPNPFuncName::DPNP_FN_RNG_EXPONENTIAL][eft_DBL][eft_DBL] = {
29963000
eft_DBL, (void *)dpnp_rng_exponential_default_c<double>};
@@ -3136,15 +3140,23 @@ void func_map_init_random(func_map_t &fmap)
31363140

31373141
fmap[DPNPFuncName::DPNP_FN_RNG_STANDARD_CAUCHY][eft_DBL][eft_DBL] = {
31383142
eft_DBL, (void *)dpnp_rng_standard_cauchy_default_c<double>};
3143+
fmap[DPNPFuncName::DPNP_FN_RNG_STANDARD_CAUCHY][eft_FLT][eft_FLT] = {
3144+
eft_FLT, (void *)dpnp_rng_standard_cauchy_default_c<float>};
31393145

31403146
fmap[DPNPFuncName::DPNP_FN_RNG_STANDARD_CAUCHY_EXT][eft_DBL][eft_DBL] = {
31413147
eft_DBL, (void *)dpnp_rng_standard_cauchy_ext_c<double>};
3148+
fmap[DPNPFuncName::DPNP_FN_RNG_STANDARD_CAUCHY_EXT][eft_FLT][eft_FLT] = {
3149+
eft_FLT, (void *)dpnp_rng_standard_cauchy_ext_c<float>};
31423150

31433151
fmap[DPNPFuncName::DPNP_FN_RNG_STANDARD_EXPONENTIAL][eft_DBL][eft_DBL] = {
31443152
eft_DBL, (void *)dpnp_rng_standard_exponential_default_c<double>};
3153+
fmap[DPNPFuncName::DPNP_FN_RNG_STANDARD_EXPONENTIAL][eft_FLT][eft_FLT] = {
3154+
eft_FLT, (void *)dpnp_rng_standard_exponential_default_c<float>};
31453155

31463156
fmap[DPNPFuncName::DPNP_FN_RNG_STANDARD_EXPONENTIAL_EXT][eft_DBL][eft_DBL] =
31473157
{eft_DBL, (void *)dpnp_rng_standard_exponential_ext_c<double>};
3158+
fmap[DPNPFuncName::DPNP_FN_RNG_STANDARD_EXPONENTIAL_EXT][eft_FLT][eft_FLT] =
3159+
{eft_FLT, (void *)dpnp_rng_standard_exponential_ext_c<float>};
31483160

31493161
fmap[DPNPFuncName::DPNP_FN_RNG_STANDARD_GAMMA][eft_DBL][eft_DBL] = {
31503162
eft_DBL, (void *)dpnp_rng_standard_gamma_default_c<double>};

dpnp/random/dpnp_algo_random.pyx

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,8 @@ ctypedef c_dpctl.DPCTLSyclEventRef(*fptr_dpnp_rng_beta_c_1out_t)(c_dpctl.DPCTLSy
9696
const c_dpctl.DPCTLEventVectorRef) except +
9797
ctypedef c_dpctl.DPCTLSyclEventRef(*fptr_dpnp_rng_binomial_c_1out_t)(c_dpctl.DPCTLSyclQueueRef,
9898
void * ,
99-
const int, const double,
99+
const int,
100+
const double,
100101
const size_t,
101102
const c_dpctl.DPCTLEventVectorRef) except +
102103
ctypedef c_dpctl.DPCTLSyclEventRef(*fptr_dpnp_rng_chisquare_c_1out_t)(c_dpctl.DPCTLSyclQueueRef,
@@ -585,7 +586,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_chisquare(int df, size):
585586
"""
586587

587588
# convert string type names (array.dtype) to C enum DPNPFuncType
588-
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dpnp.float64)
589+
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dpnp.default_float_type())
589590

590591
# get the FPTR data structure
591592
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_RNG_CHISQUARE_EXT, param1_type, param1_type)
@@ -1329,7 +1330,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_standard_cauchy(size):
13291330
"""
13301331

13311332
# convert string type names (array.dtype) to C enum DPNPFuncType
1332-
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dpnp.float64)
1333+
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dpnp.default_float_type())
13331334

13341335
# get the FPTR data structure
13351336
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_RNG_STANDARD_CAUCHY_EXT, param1_type, param1_type)
@@ -1364,7 +1365,7 @@ cpdef utils.dpnp_descriptor dpnp_rng_standard_exponential(size):
13641365
cdef fptr_dpnp_rng_standard_exponential_c_1out_t func
13651366

13661367
# convert string type names (array.dtype) to C enum DPNPFuncType
1367-
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dpnp.float64)
1368+
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dpnp.default_float_type())
13681369

13691370
# get the FPTR data structure
13701371
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_RNG_STANDARD_EXPONENTIAL_EXT, param1_type, param1_type)

dpnp/random/dpnp_iface_random.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -230,7 +230,7 @@ def chisquare(df, size=None):
230230
-----------
231231
Parameter ``df`` is supported as a scalar.
232232
Otherwise, :obj:`numpy.random.chisquare(df, size)` samples are drawn.
233-
Output array data type is :obj:`dpnp.float64`.
233+
Output array data type is default float type.
234234
235235
Examples
236236
--------
@@ -1533,7 +1533,7 @@ def standard_cauchy(size=None):
15331533
15341534
Limitations
15351535
-----------
1536-
Output array data type is :obj:`dpnp.float64`.
1536+
Output array data type is default float type.
15371537
15381538
Examples
15391539
--------
@@ -1562,7 +1562,7 @@ def standard_exponential(size=None):
15621562
15631563
Limitations
15641564
-----------
1565-
Output array data type is :obj:`dpnp.float64`.
1565+
Output array data type is default float type.
15661566
15671567
Examples
15681568
--------

tests/test_logic.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
import dpnp
66

7-
from .helper import get_all_dtypes
7+
from .helper import get_all_dtypes, has_support_aspect64
88

99

1010
@pytest.mark.parametrize("type", get_all_dtypes())
@@ -40,6 +40,9 @@ def test_all(type, shape):
4040
assert_allclose(dpnp_res, np_res)
4141

4242

43+
@pytest.mark.skipif(
44+
not has_support_aspect64(), reason="Aborted on Iris Xe: SAT-5988"
45+
)
4346
@pytest.mark.parametrize("type", get_all_dtypes(no_bool=True, no_complex=True))
4447
def test_allclose(type):
4548
a = numpy.random.rand(10)

tests/test_manipulation.py

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,29 @@
44

55
import dpnp
66

7+
from .helper import (
8+
get_all_dtypes,
9+
get_complex_dtypes,
10+
get_float_dtypes,
11+
)
12+
713
testdata = []
814
testdata += [
915
([True, False, True], dtype)
10-
for dtype in ["float32", "float64", "int32", "int64", "bool"]
16+
for dtype in get_all_dtypes(no_none=True, no_complex=True)
1117
]
1218
testdata += [
13-
([1, -1, 0], dtype) for dtype in ["float32", "float64", "int32", "int64"]
19+
([1, -1, 0], dtype)
20+
for dtype in get_all_dtypes(no_none=True, no_bool=True, no_complex=True)
1421
]
15-
testdata += [([0.1, 0.0, -0.1], dtype) for dtype in ["float32", "float64"]]
16-
testdata += [([1j, -1j, 1 - 2j], dtype) for dtype in ["complex128"]]
22+
testdata += [([0.1, 0.0, -0.1], dtype) for dtype in get_float_dtypes()]
23+
testdata += [([1j, -1j, 1 - 2j], dtype) for dtype in get_complex_dtypes()]
1724

1825

19-
@pytest.mark.parametrize("in_obj,out_dtype", testdata)
26+
@pytest.mark.parametrize("in_obj, out_dtype", testdata)
2027
def test_copyto_dtype(in_obj, out_dtype):
28+
if out_dtype == dpnp.complex64:
29+
pytest.skip("SAT-6016: dpnp.copyto() do not work with complex64 dtype")
2130
ndarr = numpy.array(in_obj)
2231
expected = numpy.empty(ndarr.size, dtype=out_dtype)
2332
numpy.copyto(expected, ndarr)

tests/test_mixins.py

Lines changed: 27 additions & 58 deletions
Original file line numberDiff line numberDiff line change
@@ -1,75 +1,44 @@
11
import unittest
22

3-
import numpy
4-
5-
import dpnp as inp
3+
from tests.third_party.cupy import testing
64

75

86
class TestMatMul(unittest.TestCase):
9-
def test_matmul(self):
10-
array_data = [1.0, 2.0, 3.0, 4.0]
11-
size = 2
12-
13-
# DPNP
14-
array1 = inp.reshape(
15-
inp.array(array_data, dtype=inp.float64), (size, size)
16-
)
17-
array2 = inp.reshape(
18-
inp.array(array_data, dtype=inp.float64), (size, size)
19-
)
20-
result = inp.matmul(array1, array2)
21-
# print(result)
22-
23-
# original
24-
array_1 = numpy.array(array_data, dtype=numpy.float64).reshape(
25-
(size, size)
26-
)
27-
array_2 = numpy.array(array_data, dtype=numpy.float64).reshape(
28-
(size, size)
29-
)
30-
expected = numpy.matmul(array_1, array_2)
31-
# print(expected)
7+
@testing.for_float_dtypes()
8+
@testing.numpy_cupy_allclose()
9+
def test_matmul(self, xp, dtype):
10+
data = [1.0, 2.0, 3.0, 4.0]
11+
shape = (2, 2)
3212

33-
# passed
34-
numpy.testing.assert_array_equal(expected, result)
35-
# still failed
36-
# self.assertEqual(expected, result)
13+
a = xp.array(data, dtype=dtype).reshape(shape)
14+
b = xp.array(data, dtype=dtype).reshape(shape)
3715

38-
def test_matmul2(self):
39-
array_data1 = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
40-
array_data2 = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]
16+
return xp.matmul(a, b)
4117

42-
# DPNP
43-
array1 = inp.reshape(inp.array(array_data1, dtype=inp.float64), (3, 2))
44-
array2 = inp.reshape(inp.array(array_data2, dtype=inp.float64), (2, 4))
45-
result = inp.matmul(array1, array2)
46-
# print(result)
18+
@testing.for_float_dtypes()
19+
@testing.numpy_cupy_allclose()
20+
def test_matmul2(self, xp, dtype):
21+
data1 = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0]
22+
data2 = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0]
4723

48-
# original
49-
array_1 = numpy.array(array_data1, dtype=numpy.float64).reshape((3, 2))
50-
array_2 = numpy.array(array_data2, dtype=numpy.float64).reshape((2, 4))
51-
expected = numpy.matmul(array_1, array_2)
52-
# print(expected)
24+
a = xp.array(data1, dtype=dtype).reshape(3, 2)
25+
b = xp.array(data2, dtype=dtype).reshape(2, 4)
5326

54-
numpy.testing.assert_array_equal(expected, result)
27+
return xp.matmul(a, b)
5528

56-
def test_matmul3(self):
57-
array_data1 = numpy.full((513, 513), 5)
58-
array_data2 = numpy.full((513, 513), 2)
59-
out = numpy.empty((513, 513), dtype=numpy.float64)
29+
@testing.for_float_dtypes()
30+
@testing.numpy_cupy_allclose()
31+
def test_matmul3(self, xp, dtype):
32+
data1 = xp.full((513, 513), 5)
33+
data2 = xp.full((513, 513), 2)
34+
out = xp.empty((513, 513), dtype=dtype)
6035

61-
# DPNP
62-
array1 = inp.array(array_data1, dtype=inp.float64)
63-
array2 = inp.array(array_data2, dtype=inp.float64)
64-
out1 = inp.array(out, dtype=inp.float64)
65-
result = inp.matmul(array1, array2, out=out1)
36+
a = xp.array(data1, dtype=dtype)
37+
b = xp.array(data2, dtype=dtype)
6638

67-
# original
68-
array_1 = numpy.array(array_data1, dtype=numpy.float64)
69-
array_2 = numpy.array(array_data2, dtype=numpy.float64)
70-
expected = numpy.matmul(array_1, array_2, out=out)
39+
xp.matmul(a, b, out=out)
7140

72-
numpy.testing.assert_array_equal(expected, result)
41+
return out
7342

7443

7544
if __name__ == "__main__":

0 commit comments

Comments
 (0)