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

Unskip tests passing with dpnp 0.9.0rc1 #606

Merged
merged 10 commits into from
Oct 29, 2021
79 changes: 35 additions & 44 deletions numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,19 @@
from ._helper import args_string, wrapper_function
from .dpnp_skip_test import dpnp_skip_test as skip_test

filter_strings = [
"level_zero:gpu:0",
"opencl:gpu:0",
"opencl:cpu:0",
]

filter_strings_with_skips_for_opencl = [
"level_zero:gpu:0",
pytest.param("opencl:gpu:0", marks=pytest.mark.skip(reason="Freeze")),
pytest.param("opencl:cpu:0", marks=pytest.mark.skip(reason="Segmentation fault")),
# pytest.param("opencl:cpu:0", marks=pytest.mark.xfail(reason="Segmentation fault")), # run with --boxed
]


# From https://github.com/IntelPython/dpnp/blob/0.4.0/tests/test_linalg.py#L8
def vvsort(val, vec):
Expand All @@ -48,18 +61,6 @@ def vvsort(val, vec):
vec[k, imax] = temp


list_of_filter_strs = [
"opencl:gpu:0",
# "level_zero:gpu:0",
# "opencl:cpu:0",
]


@pytest.fixture(params=list_of_filter_strs)
def filter_str(request):
return request.param


def get_fn(name, nargs):
args = args_string(nargs)
return wrapper_function(args, f"np.{name}({args})", globals())
Expand All @@ -86,13 +87,11 @@ def eig_input(request):
return symm_a


@pytest.mark.skip(reason="Freeze...")
@pytest.mark.parametrize("filter_str", filter_strings_with_skips_for_opencl)
def test_eig(filter_str, eig_input, capfd):
if skip_test(filter_str):
pytest.skip()

if filter_str == "opencl:cpu:0":
pytest.skip("Segfaults with device type level_zero:gpu:0")
a = eig_input
fn = get_fn("linalg.eig", 1)
f = njit(fn)
Expand Down Expand Up @@ -153,14 +152,11 @@ def dot_name(request):
return request.param


@pytest.mark.skip(reason="Freeze...")
@pytest.mark.parametrize("filter_str", filter_strings_with_skips_for_opencl)
def test_dot(filter_str, dot_name, dot_input, dtype, capfd):
if skip_test(filter_str):
pytest.skip()

if filter_str == "opencl:cpu:0":
pytest.skip("dpnp produces error for OpenCL CPU device")

a, b = dot_input

if dot_name == "vdot":
Expand All @@ -182,14 +178,11 @@ def test_dot(filter_str, dot_name, dot_input, dtype, capfd):
assert np.allclose(actual, expected)


@pytest.mark.skip(reason="Freeze...")
@pytest.mark.parametrize("filter_str", filter_strings_with_skips_for_opencl)
def test_matmul(filter_str, dtype, capfd):
if skip_test(filter_str):
pytest.skip()

if filter_str == "level_zero:gpu:0":
pytest.skip("Segfaults with device type level_zero:gpu:0")

a = np.array(np.random.random(10 * 2), dtype=dtype).reshape(10, 2)
b = np.array(np.random.random(2 * 10), dtype=dtype).reshape(2, 10)
fn = get_fn("matmul", 2)
Expand Down Expand Up @@ -241,6 +234,7 @@ def det_input(request):
return request.param


@pytest.mark.parametrize("filter_str", filter_strings)
def test_det(filter_str, det_input, dtype, capfd):
if skip_test(filter_str):
pytest.skip()
Expand All @@ -259,14 +253,11 @@ def test_det(filter_str, det_input, dtype, capfd):
assert np.allclose(actual, expected)


@pytest.mark.skip(reason="Freeze...")
@pytest.mark.parametrize("filter_str", filter_strings_with_skips_for_opencl)
def test_multi_dot(filter_str, capfd):
if skip_test(filter_str):
pytest.skip()

if filter_str == "level_zero:gpu:0":
pytest.skip("Segfaults with device type level_zero:gpu:0")

def fn(A, B, C, D):
c = np.linalg.multi_dot([A, B, C, D])
return c
Expand Down Expand Up @@ -307,14 +298,11 @@ def matrix_power_input(request):
return request.param


@pytest.mark.skip(reason="Freeze...")
@pytest.mark.parametrize("filter_str", filter_strings_with_skips_for_opencl)
def test_matrix_power(filter_str, matrix_power_input, power, dtype, capfd):
if skip_test(filter_str):
pytest.skip()

if filter_str == "level_zero:gpu:0":
pytest.skip("Segfaults with device type level_zero:gpu:0")

a = np.array(matrix_power_input, dtype=dtype)
fn = get_fn("linalg.matrix_power", 2)
f = njit(fn)
Expand All @@ -329,15 +317,21 @@ def test_matrix_power(filter_str, matrix_power_input, power, dtype, capfd):
assert np.allclose(actual, expected)


list_of_matrix_rank_input = [np.eye(4), np.ones((4,)), np.ones((4, 4)), np.zeros((4,))]


@pytest.fixture(params=list_of_matrix_rank_input)
def matrix_rank_input(request):
return request.param


@pytest.mark.skip(reason="dpnp does not support it yet")
@pytest.mark.parametrize("filter_str", filter_strings)
@pytest.mark.parametrize(
"matrix_rank_input",
[
pytest.param(
np.eye(4), marks=pytest.mark.xfail(reason="dpnp does not support it yet")
),
np.ones((4,)),
pytest.param(
np.ones((4, 4)),
marks=pytest.mark.xfail(reason="dpnp does not support it yet"),
),
np.zeros((4,)),
],
)
def test_matrix_rank(filter_str, matrix_rank_input, capfd):
if skip_test(filter_str):
pytest.skip()
Expand All @@ -355,14 +349,11 @@ def test_matrix_rank(filter_str, matrix_rank_input, capfd):
assert np.allclose(actual, expected)


@pytest.mark.skip(reason="Freeze...")
@pytest.mark.parametrize("filter_str", filter_strings_with_skips_for_opencl)
def test_eigvals(filter_str, eig_input, capfd):
if skip_test(filter_str):
pytest.skip()

if filter_str == "level_zero:gpu:0":
pytest.skip("Segfaults with device type level_zero:gpu:0")

a = eig_input
fn = get_fn("linalg.eigvals", 1)
f = njit(fn)
Expand Down
7 changes: 3 additions & 4 deletions numba_dppy/tests/njit_tests/dpnp/test_numpy_statistics.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

from ._helper import wrapper_function
from .dpnp_skip_test import dpnp_skip_test as skip_test
from .test_numpy_linalg import filter_strings_with_skips_for_opencl

list_of_filter_strs = [
"opencl:gpu:0",
Expand Down Expand Up @@ -84,7 +85,7 @@ def unary_op(request):
return wrapper_function("a", f"np.{request.param}(a)", globals()), request.param


@pytest.mark.skip(reason="Freeze...")
@pytest.mark.parametrize("filter_str", filter_strings_with_skips_for_opencl)
def test_unary_ops(filter_str, unary_op, input_arrays, get_shape, capfd):
if skip_test(filter_str):
pytest.skip()
Expand All @@ -93,9 +94,7 @@ def test_unary_ops(filter_str, unary_op, input_arrays, get_shape, capfd):
op, name = unary_op
if name != "cov":
a = np.reshape(a, get_shape)
else:
if filter_str == "level_zero:gpu:0":
pytest.skip("Segfaults with device type level_zero:gpu:0")

actual = np.empty(shape=a.shape, dtype=a.dtype)
expected = np.empty(shape=a.shape, dtype=a.dtype)

Expand Down