diff --git a/dpnp/backend/kernels/dpnp_krnl_random.cpp b/dpnp/backend/kernels/dpnp_krnl_random.cpp index a6ed5794c244..a342151c4cce 100644 --- a/dpnp/backend/kernels/dpnp_krnl_random.cpp +++ b/dpnp/backend/kernels/dpnp_krnl_random.cpp @@ -2988,9 +2988,13 @@ void func_map_init_random(func_map_t &fmap) fmap[DPNPFuncName::DPNP_FN_RNG_CHISQUARE][eft_DBL][eft_DBL] = { eft_DBL, (void *)dpnp_rng_chisquare_default_c}; + fmap[DPNPFuncName::DPNP_FN_RNG_CHISQUARE][eft_FLT][eft_FLT] = { + eft_FLT, (void *)dpnp_rng_chisquare_default_c}; fmap[DPNPFuncName::DPNP_FN_RNG_CHISQUARE_EXT][eft_DBL][eft_DBL] = { eft_DBL, (void *)dpnp_rng_chisquare_ext_c}; + fmap[DPNPFuncName::DPNP_FN_RNG_CHISQUARE_EXT][eft_FLT][eft_FLT] = { + eft_FLT, (void *)dpnp_rng_chisquare_ext_c}; fmap[DPNPFuncName::DPNP_FN_RNG_EXPONENTIAL][eft_DBL][eft_DBL] = { eft_DBL, (void *)dpnp_rng_exponential_default_c}; @@ -3136,15 +3140,23 @@ void func_map_init_random(func_map_t &fmap) fmap[DPNPFuncName::DPNP_FN_RNG_STANDARD_CAUCHY][eft_DBL][eft_DBL] = { eft_DBL, (void *)dpnp_rng_standard_cauchy_default_c}; + fmap[DPNPFuncName::DPNP_FN_RNG_STANDARD_CAUCHY][eft_FLT][eft_FLT] = { + eft_FLT, (void *)dpnp_rng_standard_cauchy_default_c}; fmap[DPNPFuncName::DPNP_FN_RNG_STANDARD_CAUCHY_EXT][eft_DBL][eft_DBL] = { eft_DBL, (void *)dpnp_rng_standard_cauchy_ext_c}; + fmap[DPNPFuncName::DPNP_FN_RNG_STANDARD_CAUCHY_EXT][eft_FLT][eft_FLT] = { + eft_FLT, (void *)dpnp_rng_standard_cauchy_ext_c}; fmap[DPNPFuncName::DPNP_FN_RNG_STANDARD_EXPONENTIAL][eft_DBL][eft_DBL] = { eft_DBL, (void *)dpnp_rng_standard_exponential_default_c}; + fmap[DPNPFuncName::DPNP_FN_RNG_STANDARD_EXPONENTIAL][eft_FLT][eft_FLT] = { + eft_FLT, (void *)dpnp_rng_standard_exponential_default_c}; fmap[DPNPFuncName::DPNP_FN_RNG_STANDARD_EXPONENTIAL_EXT][eft_DBL][eft_DBL] = {eft_DBL, (void *)dpnp_rng_standard_exponential_ext_c}; + fmap[DPNPFuncName::DPNP_FN_RNG_STANDARD_EXPONENTIAL_EXT][eft_FLT][eft_FLT] = + {eft_FLT, (void *)dpnp_rng_standard_exponential_ext_c}; fmap[DPNPFuncName::DPNP_FN_RNG_STANDARD_GAMMA][eft_DBL][eft_DBL] = { eft_DBL, (void *)dpnp_rng_standard_gamma_default_c}; diff --git a/dpnp/random/dpnp_algo_random.pyx b/dpnp/random/dpnp_algo_random.pyx index b46b4827f7ed..e9206bd6682c 100644 --- a/dpnp/random/dpnp_algo_random.pyx +++ b/dpnp/random/dpnp_algo_random.pyx @@ -96,7 +96,8 @@ ctypedef c_dpctl.DPCTLSyclEventRef(*fptr_dpnp_rng_beta_c_1out_t)(c_dpctl.DPCTLSy const c_dpctl.DPCTLEventVectorRef) except + ctypedef c_dpctl.DPCTLSyclEventRef(*fptr_dpnp_rng_binomial_c_1out_t)(c_dpctl.DPCTLSyclQueueRef, void * , - const int, const double, + const int, + const double, const size_t, const c_dpctl.DPCTLEventVectorRef) except + 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): """ # convert string type names (array.dtype) to C enum DPNPFuncType - cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dpnp.float64) + cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dpnp.default_float_type()) # get the FPTR data structure 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): """ # convert string type names (array.dtype) to C enum DPNPFuncType - cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dpnp.float64) + cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dpnp.default_float_type()) # get the FPTR data structure 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): cdef fptr_dpnp_rng_standard_exponential_c_1out_t func # convert string type names (array.dtype) to C enum DPNPFuncType - cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dpnp.float64) + cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(dpnp.default_float_type()) # get the FPTR data structure cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_RNG_STANDARD_EXPONENTIAL_EXT, param1_type, param1_type) diff --git a/dpnp/random/dpnp_iface_random.py b/dpnp/random/dpnp_iface_random.py index f8d380db2ece..7a7f981f0945 100644 --- a/dpnp/random/dpnp_iface_random.py +++ b/dpnp/random/dpnp_iface_random.py @@ -230,7 +230,7 @@ def chisquare(df, size=None): ----------- Parameter ``df`` is supported as a scalar. Otherwise, :obj:`numpy.random.chisquare(df, size)` samples are drawn. - Output array data type is :obj:`dpnp.float64`. + Output array data type is default float type. Examples -------- @@ -1533,7 +1533,7 @@ def standard_cauchy(size=None): Limitations ----------- - Output array data type is :obj:`dpnp.float64`. + Output array data type is default float type. Examples -------- @@ -1562,7 +1562,7 @@ def standard_exponential(size=None): Limitations ----------- - Output array data type is :obj:`dpnp.float64`. + Output array data type is default float type. Examples -------- diff --git a/tests/test_logic.py b/tests/test_logic.py index 982c58942f95..11f358b3e688 100644 --- a/tests/test_logic.py +++ b/tests/test_logic.py @@ -4,7 +4,7 @@ import dpnp -from .helper import get_all_dtypes +from .helper import get_all_dtypes, has_support_aspect64 @pytest.mark.parametrize("type", get_all_dtypes()) @@ -40,6 +40,9 @@ def test_all(type, shape): assert_allclose(dpnp_res, np_res) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Aborted on Iris Xe: SAT-5988" +) @pytest.mark.parametrize("type", get_all_dtypes(no_bool=True, no_complex=True)) def test_allclose(type): a = numpy.random.rand(10) diff --git a/tests/test_manipulation.py b/tests/test_manipulation.py index e0520d62fd98..c40ec0786ff4 100644 --- a/tests/test_manipulation.py +++ b/tests/test_manipulation.py @@ -4,20 +4,29 @@ import dpnp +from .helper import ( + get_all_dtypes, + get_complex_dtypes, + get_float_dtypes, +) + testdata = [] testdata += [ ([True, False, True], dtype) - for dtype in ["float32", "float64", "int32", "int64", "bool"] + for dtype in get_all_dtypes(no_none=True, no_complex=True) ] testdata += [ - ([1, -1, 0], dtype) for dtype in ["float32", "float64", "int32", "int64"] + ([1, -1, 0], dtype) + for dtype in get_all_dtypes(no_none=True, no_bool=True, no_complex=True) ] -testdata += [([0.1, 0.0, -0.1], dtype) for dtype in ["float32", "float64"]] -testdata += [([1j, -1j, 1 - 2j], dtype) for dtype in ["complex128"]] +testdata += [([0.1, 0.0, -0.1], dtype) for dtype in get_float_dtypes()] +testdata += [([1j, -1j, 1 - 2j], dtype) for dtype in get_complex_dtypes()] -@pytest.mark.parametrize("in_obj,out_dtype", testdata) +@pytest.mark.parametrize("in_obj, out_dtype", testdata) def test_copyto_dtype(in_obj, out_dtype): + if out_dtype == dpnp.complex64: + pytest.skip("SAT-6016: dpnp.copyto() do not work with complex64 dtype") ndarr = numpy.array(in_obj) expected = numpy.empty(ndarr.size, dtype=out_dtype) numpy.copyto(expected, ndarr) diff --git a/tests/test_mixins.py b/tests/test_mixins.py index e2ffb26ffd24..01b836b955a0 100644 --- a/tests/test_mixins.py +++ b/tests/test_mixins.py @@ -1,75 +1,44 @@ import unittest -import numpy - -import dpnp as inp +from tests.third_party.cupy import testing class TestMatMul(unittest.TestCase): - def test_matmul(self): - array_data = [1.0, 2.0, 3.0, 4.0] - size = 2 - - # DPNP - array1 = inp.reshape( - inp.array(array_data, dtype=inp.float64), (size, size) - ) - array2 = inp.reshape( - inp.array(array_data, dtype=inp.float64), (size, size) - ) - result = inp.matmul(array1, array2) - # print(result) - - # original - array_1 = numpy.array(array_data, dtype=numpy.float64).reshape( - (size, size) - ) - array_2 = numpy.array(array_data, dtype=numpy.float64).reshape( - (size, size) - ) - expected = numpy.matmul(array_1, array_2) - # print(expected) + @testing.for_float_dtypes() + @testing.numpy_cupy_allclose() + def test_matmul(self, xp, dtype): + data = [1.0, 2.0, 3.0, 4.0] + shape = (2, 2) - # passed - numpy.testing.assert_array_equal(expected, result) - # still failed - # self.assertEqual(expected, result) + a = xp.array(data, dtype=dtype).reshape(shape) + b = xp.array(data, dtype=dtype).reshape(shape) - def test_matmul2(self): - array_data1 = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] - array_data2 = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0] + return xp.matmul(a, b) - # DPNP - array1 = inp.reshape(inp.array(array_data1, dtype=inp.float64), (3, 2)) - array2 = inp.reshape(inp.array(array_data2, dtype=inp.float64), (2, 4)) - result = inp.matmul(array1, array2) - # print(result) + @testing.for_float_dtypes() + @testing.numpy_cupy_allclose() + def test_matmul2(self, xp, dtype): + data1 = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0] + data2 = [1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0] - # original - array_1 = numpy.array(array_data1, dtype=numpy.float64).reshape((3, 2)) - array_2 = numpy.array(array_data2, dtype=numpy.float64).reshape((2, 4)) - expected = numpy.matmul(array_1, array_2) - # print(expected) + a = xp.array(data1, dtype=dtype).reshape(3, 2) + b = xp.array(data2, dtype=dtype).reshape(2, 4) - numpy.testing.assert_array_equal(expected, result) + return xp.matmul(a, b) - def test_matmul3(self): - array_data1 = numpy.full((513, 513), 5) - array_data2 = numpy.full((513, 513), 2) - out = numpy.empty((513, 513), dtype=numpy.float64) + @testing.for_float_dtypes() + @testing.numpy_cupy_allclose() + def test_matmul3(self, xp, dtype): + data1 = xp.full((513, 513), 5) + data2 = xp.full((513, 513), 2) + out = xp.empty((513, 513), dtype=dtype) - # DPNP - array1 = inp.array(array_data1, dtype=inp.float64) - array2 = inp.array(array_data2, dtype=inp.float64) - out1 = inp.array(out, dtype=inp.float64) - result = inp.matmul(array1, array2, out=out1) + a = xp.array(data1, dtype=dtype) + b = xp.array(data2, dtype=dtype) - # original - array_1 = numpy.array(array_data1, dtype=numpy.float64) - array_2 = numpy.array(array_data2, dtype=numpy.float64) - expected = numpy.matmul(array_1, array_2, out=out) + xp.matmul(a, b, out=out) - numpy.testing.assert_array_equal(expected, result) + return out if __name__ == "__main__": diff --git a/tests/test_random.py b/tests/test_random.py index fc3777978e7f..93026f64b0dc 100644 --- a/tests/test_random.py +++ b/tests/test_random.py @@ -7,6 +7,8 @@ import dpnp.random +from .helper import has_support_aspect64 + class TestDistribution(unittest.TestCase): def check_extreme_value(self, dist_name, val, params): @@ -149,6 +151,9 @@ def test_randn_normal_distribution(): assert math.isclose(mean, expected_mean, abs_tol=0.03) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsBeta(TestDistribution): def test_moments(self): @@ -174,6 +179,9 @@ def test_seed(self): self.check_seed("beta", {"a": a, "b": b}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsBinomial(TestDistribution): def test_extreme_value(self): @@ -212,6 +220,9 @@ def test_seed(self): self.check_seed("binomial", {"n": n, "p": p}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsChisquare(TestDistribution): def test_invalid_args(self): @@ -223,6 +234,9 @@ def test_seed(self): self.check_seed("chisquare", {"df": df}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsExponential(TestDistribution): def test_invalid_args(self): @@ -234,6 +248,9 @@ def test_seed(self): self.check_seed("exponential", {"scale": scale}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsF(TestDistribution): def test_moments(self): @@ -267,6 +284,9 @@ def test_seed(self): self.check_seed("f", {"dfnum": dfnum, "dfden": dfden}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsGamma(TestDistribution): def test_moments(self): @@ -317,6 +337,9 @@ def test_seed(self): self.check_seed("geometric", {"p": p}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsGumbel(TestDistribution): def test_extreme_value(self): @@ -348,6 +371,9 @@ def test_seed(self): self.check_seed("gumbel", {"loc": loc, "scale": scale}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-6001" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsHypergeometric(TestDistribution): def test_extreme_value(self): @@ -434,6 +460,9 @@ def test_seed(self): ) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsLaplace(TestDistribution): def test_extreme_value(self): @@ -464,6 +493,9 @@ def test_seed(self): self.check_seed("laplace", {"loc": loc, "scale": scale}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsLogistic(TestDistribution): def test_moments(self): @@ -489,6 +521,9 @@ def test_seed(self): self.check_seed("logistic", {"loc": loc, "scale": scale}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsLognormal(TestDistribution): def test_extreme_value(self): @@ -524,6 +559,9 @@ def test_seed(self): self.check_seed("lognormal", {"mean": mean, "sigma": sigma}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsMultinomial(TestDistribution): def test_extreme_value(self): @@ -620,6 +658,9 @@ def test_seed(self): self.check_seed("multivariate_normal", {"mean": mean, "cov": cov}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsNegativeBinomial(TestDistribution): def test_extreme_value(self): @@ -651,6 +692,9 @@ def test_seed(self): self.check_seed("negative_binomial", {"n": n, "p": p}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) class TestDistributionsNormal(TestDistribution): def test_extreme_value(self): loc = 5 @@ -680,6 +724,9 @@ def test_seed(self): self.check_seed("normal", {"loc": loc, "scale": scale}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsNoncentralChisquare: @pytest.mark.parametrize( @@ -725,6 +772,9 @@ def test_seed(self, df): assert_allclose(a1, a2, rtol=1e-07, atol=0) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsPareto(TestDistribution): def test_moments(self): @@ -743,6 +793,9 @@ def test_seed(self): self.check_seed("pareto", {"a": a}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsPoisson(TestDistribution): def test_extreme_value(self): @@ -764,6 +817,9 @@ def test_seed(self): self.check_seed("poisson", {"lam": lam}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsPower(TestDistribution): def test_moments(self): @@ -783,6 +839,9 @@ def test_seed(self): self.check_seed("power", {"a": a}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsRayleigh(TestDistribution): def test_extreme_value(self): @@ -824,6 +883,9 @@ def test_seed(self): self.check_seed("standard_exponential", {}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsStandardGamma(TestDistribution): def test_extreme_value(self): @@ -855,6 +917,9 @@ def test_seed(self): self.check_seed("standard_normal", {}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsStandardT(TestDistribution): def test_moments(self): @@ -873,6 +938,9 @@ def test_seed(self): self.check_seed("standard_t", {"df": 10.0}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsTriangular(TestDistribution): def test_moments(self): @@ -919,6 +987,9 @@ def test_seed(self): ) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) class TestDistributionsUniform(TestDistribution): def test_extreme_value(self): low = 1.0 @@ -943,6 +1014,9 @@ def test_seed(self): self.check_seed("uniform", {"low": low, "high": high}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsVonmises: @pytest.mark.parametrize( @@ -983,6 +1057,9 @@ def test_seed(self, kappa): assert_allclose(a1, a2, rtol=1e-07, atol=0) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsWald(TestDistribution): def test_moments(self): @@ -1014,6 +1091,9 @@ def test_seed(self): self.check_seed("wald", {"mean": mean, "scale": scale}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsWeibull(TestDistribution): def test_extreme_value(self): @@ -1030,6 +1110,9 @@ def test_seed(self): self.check_seed("weibull", {"a": a}) +@pytest.mark.skipif( + not has_support_aspect64(), reason="Failed on Iris Xe: SAT-5989" +) @pytest.mark.usefixtures("allow_fall_back_on_numpy") class TestDistributionsZipf(TestDistribution): def test_invalid_args(self):