Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update some of the dpnp tests to run on Iris Xe #1472

Merged
merged 13 commits into from
Jul 31, 2023
2 changes: 1 addition & 1 deletion dpnp/dpnp_array.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ class dpnp_array:
def __init__(
self,
shape,
dtype="f8",
dtype=None,
buffer=None,
offset=0,
strides=None,
Expand Down
37 changes: 0 additions & 37 deletions tests/skipped_tests.tbl
Original file line number Diff line number Diff line change
Expand Up @@ -39,43 +39,6 @@ tests/third_party/intel/test_zero_copy_test1.py::test_dpnp_interaction_with_dpct
tests/test_arraymanipulation.py::TestHstack::test_generator
tests/test_arraymanipulation.py::TestVstack::test_generator

tests/test_dparray.py::test_astype[[]-float64-float64]
tests/test_dparray.py::test_astype[[]-float64-float32]
tests/test_dparray.py::test_astype[[]-float64-int64]
tests/test_dparray.py::test_astype[[]-float64-int32]
tests/test_dparray.py::test_astype[[]-float64-bool]
tests/test_dparray.py::test_astype[[]-float64-complex]
tests/test_dparray.py::test_astype[[]-float32-float64]
tests/test_dparray.py::test_astype[[]-float32-float32]
tests/test_dparray.py::test_astype[[]-float32-int64]
tests/test_dparray.py::test_astype[[]-float32-int32]
tests/test_dparray.py::test_astype[[]-float32-bool]
tests/test_dparray.py::test_astype[[]-float32-complex]
tests/test_dparray.py::test_astype[[]-int64-float64]
tests/test_dparray.py::test_astype[[]-int64-float32]
tests/test_dparray.py::test_astype[[]-int64-int64]
tests/test_dparray.py::test_astype[[]-int64-int32]
tests/test_dparray.py::test_astype[[]-int64-bool]
tests/test_dparray.py::test_astype[[]-int64-complex]
tests/test_dparray.py::test_astype[[]-int32-float64]
tests/test_dparray.py::test_astype[[]-int32-float32]
tests/test_dparray.py::test_astype[[]-int32-int64]
tests/test_dparray.py::test_astype[[]-int32-int32]
tests/test_dparray.py::test_astype[[]-int32-bool]
tests/test_dparray.py::test_astype[[]-int32-complex]
tests/test_dparray.py::test_astype[[]-bool-float64]
tests/test_dparray.py::test_astype[[]-bool-float32]
tests/test_dparray.py::test_astype[[]-bool-int64]
tests/test_dparray.py::test_astype[[]-bool-int32]
tests/test_dparray.py::test_astype[[]-bool-bool]
tests/test_dparray.py::test_astype[[]-bool-complex]
tests/test_dparray.py::test_astype[[]-complex-float64]
tests/test_dparray.py::test_astype[[]-complex-float32]
tests/test_dparray.py::test_astype[[]-complex-int64]
tests/test_dparray.py::test_astype[[]-complex-int32]
tests/test_dparray.py::test_astype[[]-complex-bool]
tests/test_dparray.py::test_astype[[]-complex-complex]

tests/test_linalg.py::test_cond[-1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
tests/test_linalg.py::test_cond[1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
tests/test_linalg.py::test_cond[-2-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
Expand Down
37 changes: 0 additions & 37 deletions tests/skipped_tests_gpu.tbl
Original file line number Diff line number Diff line change
Expand Up @@ -239,43 +239,6 @@ tests/third_party/intel/test_zero_copy_test1.py::test_dpnp_interaction_with_dpct
tests/test_arraymanipulation.py::TestHstack::test_generator
tests/test_arraymanipulation.py::TestVstack::test_generator

tests/test_dparray.py::test_astype[[]-float64-float64]
tests/test_dparray.py::test_astype[[]-float64-float32]
tests/test_dparray.py::test_astype[[]-float64-int64]
tests/test_dparray.py::test_astype[[]-float64-int32]
tests/test_dparray.py::test_astype[[]-float64-bool]
tests/test_dparray.py::test_astype[[]-float64-complex]
tests/test_dparray.py::test_astype[[]-float32-float64]
tests/test_dparray.py::test_astype[[]-float32-float32]
tests/test_dparray.py::test_astype[[]-float32-int64]
tests/test_dparray.py::test_astype[[]-float32-int32]
tests/test_dparray.py::test_astype[[]-float32-bool]
tests/test_dparray.py::test_astype[[]-float32-complex]
tests/test_dparray.py::test_astype[[]-int64-float64]
tests/test_dparray.py::test_astype[[]-int64-float32]
tests/test_dparray.py::test_astype[[]-int64-int64]
tests/test_dparray.py::test_astype[[]-int64-int32]
tests/test_dparray.py::test_astype[[]-int64-bool]
tests/test_dparray.py::test_astype[[]-int64-complex]
tests/test_dparray.py::test_astype[[]-int32-float64]
tests/test_dparray.py::test_astype[[]-int32-float32]
tests/test_dparray.py::test_astype[[]-int32-int64]
tests/test_dparray.py::test_astype[[]-int32-int32]
tests/test_dparray.py::test_astype[[]-int32-bool]
tests/test_dparray.py::test_astype[[]-int32-complex]
tests/test_dparray.py::test_astype[[]-bool-float64]
tests/test_dparray.py::test_astype[[]-bool-float32]
tests/test_dparray.py::test_astype[[]-bool-int64]
tests/test_dparray.py::test_astype[[]-bool-int32]
tests/test_dparray.py::test_astype[[]-bool-bool]
tests/test_dparray.py::test_astype[[]-bool-complex]
tests/test_dparray.py::test_astype[[]-complex-float64]
tests/test_dparray.py::test_astype[[]-complex-float32]
tests/test_dparray.py::test_astype[[]-complex-int64]
tests/test_dparray.py::test_astype[[]-complex-int32]
tests/test_dparray.py::test_astype[[]-complex-bool]
tests/test_dparray.py::test_astype[[]-complex-complex]

tests/test_linalg.py::test_cond[-1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
tests/test_linalg.py::test_cond[1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
tests/test_linalg.py::test_cond[-2-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
Expand Down
67 changes: 22 additions & 45 deletions tests/test_amin_amax.py
Original file line number Diff line number Diff line change
@@ -1,61 +1,46 @@
import numpy
import pytest
from numpy.testing import assert_allclose, assert_array_equal

import dpnp

from .helper import get_all_dtypes

@pytest.mark.parametrize("type", [numpy.float64], ids=["float64"])
def test_amax_float64(type):

@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True))
def test_amax(dtype):
a = numpy.array(
[
[[-2.0, 3.0], [9.1, 0.2]],
[[-2.0, 5.0], [-2, -1.2]],
[[1.0, -2.0], [5.0, -1.1]],
]
],
dtype=dtype,
)
ia = dpnp.array(a)

for axis in range(len(a)):
result = dpnp.amax(ia, axis=axis)
expected = numpy.amax(a, axis=axis)
numpy.testing.assert_array_equal(expected, result)


@pytest.mark.parametrize("type", [numpy.int64], ids=["int64"])
def test_amax_int(type):
a = numpy.array([1, 0, 2, -3, -1, 2, 21, -9])
ia = dpnp.array(a)
assert_allclose(expected, result)

result = dpnp.amax(ia)
expected = numpy.amax(a)
numpy.testing.assert_array_equal(expected, result)


@pytest.mark.parametrize("type", [numpy.float64], ids=["float64"])
def test_amin_float64(type):
@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True))
def test_amin(dtype):
a = numpy.array(
[
[[-2.0, 3.0], [9.1, 0.2]],
[[-2.0, 5.0], [-2, -1.2]],
[[1.0, -2.0], [5.0, -1.1]],
]
],
dtype=dtype,
)
ia = dpnp.array(a)

for axis in range(len(a)):
result = dpnp.amin(ia, axis=axis)
expected = numpy.amin(a, axis=axis)
numpy.testing.assert_array_equal(expected, result)


@pytest.mark.parametrize("type", [numpy.int64], ids=["int64"])
def test_amin_int(type):
a = numpy.array([1, 0, 2, -3, -1, 2, 21, -9])
ia = dpnp.array(a)

result = dpnp.amin(ia)
expected = numpy.amin(a)
numpy.testing.assert_array_equal(expected, result)
assert_allclose(expected, result)


def _get_min_max_input(type, shape):
Expand All @@ -71,46 +56,38 @@ def _get_min_max_input(type, shape):


@pytest.mark.usefixtures("allow_fall_back_on_numpy")
@pytest.mark.parametrize(
"type",
[numpy.float64, numpy.float32, numpy.int64, numpy.int32],
ids=["float64", "float32", "int64", "int32"],
)
@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True))
@pytest.mark.parametrize(
"shape", [(4,), (2, 3), (4, 5, 6)], ids=["(4,)", "(2,3)", "(4,5,6)"]
)
def test_amax(type, shape):
a = _get_min_max_input(type, shape)
def test_amax_diff_shape(dtype, shape):
a = _get_min_max_input(dtype, shape)

ia = dpnp.array(a)
vlad-perevezentsev marked this conversation as resolved.
Show resolved Hide resolved

np_res = numpy.amax(a)
dpnp_res = dpnp.amax(ia)
numpy.testing.assert_array_equal(dpnp_res, np_res)
assert_array_equal(dpnp_res, np_res)

np_res = a.max()
dpnp_res = ia.max()
numpy.testing.assert_array_equal(dpnp_res, np_res)


@pytest.mark.usefixtures("allow_fall_back_on_numpy")
@pytest.mark.parametrize(
"type",
[numpy.float64, numpy.float32, numpy.int64, numpy.int32],
ids=["float64", "float32", "int64", "int32"],
)
@pytest.mark.parametrize("dtype", get_all_dtypes(no_bool=True, no_complex=True))
@pytest.mark.parametrize(
"shape", [(4,), (2, 3), (4, 5, 6)], ids=["(4,)", "(2,3)", "(4,5,6)"]
)
def test_amin(type, shape):
a = _get_min_max_input(type, shape)
def test_amin_diff_shape(dtype, shape):
a = _get_min_max_input(dtype, shape)

ia = dpnp.array(a)

np_res = numpy.amin(a)
dpnp_res = dpnp.amin(ia)
numpy.testing.assert_array_equal(dpnp_res, np_res)
assert_array_equal(dpnp_res, np_res)

np_res = a.min()
dpnp_res = ia.min()
numpy.testing.assert_array_equal(dpnp_res, np_res)
assert_array_equal(dpnp_res, np_res)
18 changes: 15 additions & 3 deletions tests/test_arraycreation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,10 @@

import dpnp

from .helper import get_all_dtypes
from .helper import (
get_all_dtypes,
has_support_aspect64,
)


@pytest.mark.parametrize(
Expand Down Expand Up @@ -115,7 +118,12 @@ def test_eye(N, M, k, dtype, order):


@pytest.mark.usefixtures("allow_fall_back_on_numpy")
@pytest.mark.parametrize("dtype", get_all_dtypes(no_float16=False))
@pytest.mark.parametrize(
"dtype",
get_all_dtypes(
no_float16=False, no_none=False if has_support_aspect64() else True
),
)
def test_frombuffer(dtype):
buffer = b"12345678ABCDEF00"
func = lambda xp: xp.frombuffer(buffer, dtype=dtype)
Expand Down Expand Up @@ -607,7 +615,11 @@ def test_linspace(start, stop, num, dtype):
if numpy.issubdtype(dtype, dpnp.integer):
assert_allclose(func(numpy), func(dpnp), rtol=1)
else:
assert_allclose(func(numpy), func(dpnp), atol=numpy.finfo(dtype).eps)
if dtype is None and not has_support_aspect64():
dtype = dpnp.float32
assert_allclose(
func(numpy), func(dpnp), rtol=1e-06, atol=numpy.finfo(dtype).eps
)


@pytest.mark.parametrize(
Expand Down
Loading