From 2de2705270d6a063b5a056a6dadb94315c97ab25 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 29 Oct 2021 01:53:51 +0300 Subject: [PATCH 01/10] Unskip test_eig for level_zero --- numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py b/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py index 9a92305387..603c772899 100644 --- a/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py +++ b/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py @@ -86,13 +86,18 @@ def eig_input(request): return symm_a -@pytest.mark.skip(reason="Freeze...") +filter_strings = [ + "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.mark.parametrize("filter_str", filter_strings) 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) From bf946d80665ade0ff4069220894e55722683bb62 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 29 Oct 2021 02:19:02 +0300 Subject: [PATCH 02/10] Unskip test_eigvals for level_zero --- numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py b/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py index 603c772899..715564802b 100644 --- a/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py +++ b/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py @@ -86,14 +86,14 @@ def eig_input(request): return symm_a -filter_strings = [ +filter_strings_for_eig = [ "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.mark.parametrize("filter_str", filter_strings) +@pytest.mark.parametrize("filter_str", filter_strings_for_eig) def test_eig(filter_str, eig_input, capfd): if skip_test(filter_str): pytest.skip() @@ -360,14 +360,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_for_eig) 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) From bef005dd22d25ff2d38f257804b5243046de10ac Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 29 Oct 2021 02:29:48 +0300 Subject: [PATCH 03/10] Unskip test_dot for level_zero. Small refactoring --- .../njit_tests/dpnp/test_numpy_linalg.py | 24 +++++++++---------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py b/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py index 715564802b..e371a343fe 100644 --- a/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py +++ b/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py @@ -28,6 +28,14 @@ from .dpnp_skip_test import dpnp_skip_test as skip_test +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): size = val.size @@ -86,14 +94,7 @@ def eig_input(request): return symm_a -filter_strings_for_eig = [ - "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.mark.parametrize("filter_str", filter_strings_for_eig) +@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() @@ -158,14 +159,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": @@ -360,7 +358,7 @@ def test_matrix_rank(filter_str, matrix_rank_input, capfd): assert np.allclose(actual, expected) -@pytest.mark.parametrize("filter_str", filter_strings_for_eig) +@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() From 0cb8b578befbd14bb56341d0ebb3d3baae06f61e Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 29 Oct 2021 02:32:08 +0300 Subject: [PATCH 04/10] Unskip test_matmul for level_zero --- numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py b/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py index e371a343fe..90c8a7cf32 100644 --- a/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py +++ b/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py @@ -185,14 +185,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) From 163b18744b293982cf5f75e34e82495301995588 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 29 Oct 2021 02:34:45 +0300 Subject: [PATCH 05/10] Unskip test_matrix_power for level_zero --- numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py b/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py index 90c8a7cf32..efc85ec1ee 100644 --- a/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py +++ b/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py @@ -307,14 +307,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) From 1c211f4686e04f395eecd5441ac8b3172211b6eb Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 29 Oct 2021 02:41:09 +0300 Subject: [PATCH 06/10] Unskip test_numpy_statistics.py::test_unary_ops for level_zero --- numba_dppy/tests/njit_tests/dpnp/test_numpy_statistics.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/numba_dppy/tests/njit_tests/dpnp/test_numpy_statistics.py b/numba_dppy/tests/njit_tests/dpnp/test_numpy_statistics.py index e2a81332ab..d922a0a6b2 100644 --- a/numba_dppy/tests/njit_tests/dpnp/test_numpy_statistics.py +++ b/numba_dppy/tests/njit_tests/dpnp/test_numpy_statistics.py @@ -26,6 +26,8 @@ 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", @@ -84,7 +86,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() @@ -93,9 +95,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) From f40983bda14d2fef96d5cb6dd86ca6bbeaaf1f62 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 29 Oct 2021 02:52:10 +0300 Subject: [PATCH 07/10] pre-commit --- numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py | 1 - numba_dppy/tests/njit_tests/dpnp/test_numpy_statistics.py | 1 - 2 files changed, 2 deletions(-) diff --git a/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py b/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py index efc85ec1ee..9c791e58cd 100644 --- a/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py +++ b/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py @@ -27,7 +27,6 @@ from ._helper import args_string, wrapper_function from .dpnp_skip_test import dpnp_skip_test as skip_test - filter_strings_with_skips_for_opencl = [ "level_zero:gpu:0", pytest.param("opencl:gpu:0", marks=pytest.mark.skip(reason="Freeze")), diff --git a/numba_dppy/tests/njit_tests/dpnp/test_numpy_statistics.py b/numba_dppy/tests/njit_tests/dpnp/test_numpy_statistics.py index d922a0a6b2..3b6f5c128a 100644 --- a/numba_dppy/tests/njit_tests/dpnp/test_numpy_statistics.py +++ b/numba_dppy/tests/njit_tests/dpnp/test_numpy_statistics.py @@ -28,7 +28,6 @@ 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", "level_zero:gpu:0", From 1731b0da699f7d87fa2e46d93823fe96a40e1d07 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 29 Oct 2021 03:00:14 +0300 Subject: [PATCH 08/10] Unskip test_multi_dot for level_zero --- numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py b/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py index 9c791e58cd..f780ebe9d1 100644 --- a/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py +++ b/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py @@ -258,14 +258,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 From 8021e7f2075ede863cef77a80b7f5725432a58df Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 29 Oct 2021 03:12:45 +0300 Subject: [PATCH 09/10] Unskip test_matrix_rank. But not all cases work. --- .../njit_tests/dpnp/test_numpy_linalg.py | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py b/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py index f780ebe9d1..f04df296b5 100644 --- a/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py +++ b/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py @@ -27,6 +27,12 @@ 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")), @@ -322,15 +328,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() From 8c7f40ce7a7a21422fa357e36dbdff522ffbf838 Mon Sep 17 00:00:00 2001 From: Sergey Pokhodenko Date: Fri, 29 Oct 2021 03:19:34 +0300 Subject: [PATCH 10/10] Run test_det for all devices --- .../tests/njit_tests/dpnp/test_numpy_linalg.py | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py b/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py index f04df296b5..57f93d0cfd 100644 --- a/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py +++ b/numba_dppy/tests/njit_tests/dpnp/test_numpy_linalg.py @@ -61,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()) @@ -246,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()