Skip to content

Commit f1da98a

Browse files
committed
Finalize CFD support in linalg
1 parent d240d22 commit f1da98a

14 files changed

+136
-113
lines changed

.github/workflows/conda-package.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ jobs:
241241

242242
# TODO: run the whole scope once the issues on CPU are resolved
243243
- name: Run tests
244-
run: python -m pytest -q -ra --disable-warnings -vv test_arraycreation.py test_dparray.py test_fft.py test_mathematical.py test_special.py
244+
run: python -m pytest -q -ra --disable-warnings -vv test_arraycreation.py test_dparray.py test_fft.py test_linalg.py test_mathematical.py test_special.py test_sycl_queue.py
245245
env:
246246
SYCL_ENABLE_HOST_DEVICE: '1'
247247
working-directory: ${{ env.tests-path }}
@@ -416,7 +416,7 @@ jobs:
416416

417417
# TODO: run the whole scope once the issues on CPU are resolved
418418
- name: Run tests
419-
run: python -m pytest -q -ra --disable-warnings -vv test_arraycreation.py test_dparray.py test_fft.py test_mathematical.py test_special.py
419+
run: python -m pytest -q -ra --disable-warnings -vv test_arraycreation.py test_dparray.py test_fft.py test_linalg.py test_mathematical.py test_special.py test_sycl_queue.py
420420
working-directory: ${{ env.tests-path }}
421421

422422
upload_linux:

dpnp/backend/kernels/dpnp_krnl_common.cpp

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//*****************************************************************************
2-
// Copyright (c) 2016-2020, Intel Corporation
2+
// Copyright (c) 2016-2022, Intel Corporation
33
// All rights reserved.
44
//
55
// Redistribution and use in source and binary forms, with or without
@@ -97,6 +97,7 @@ void dpnp_astype_c(const void* array1_in, void* result1, const size_t size)
9797
size,
9898
dep_event_vec_ref);
9999
DPCTLEvent_WaitAndThrow(event_ref);
100+
DPCTLEvent_Delete(event_ref);
100101
}
101102

102103
template <typename _DataType, typename _ResultType>
@@ -477,6 +478,7 @@ void dpnp_dot_c(void* result_out,
477478
input2_strides,
478479
dep_event_vec_ref);
479480
DPCTLEvent_WaitAndThrow(event_ref);
481+
DPCTLEvent_Delete(event_ref);
480482
}
481483

482484
template <typename _DataType_output, typename _DataType_input1, typename _DataType_input2>
@@ -614,6 +616,7 @@ void dpnp_eig_c(const void* array_in, void* result1, void* result2, size_t size)
614616
size,
615617
dep_event_vec_ref);
616618
DPCTLEvent_WaitAndThrow(event_ref);
619+
DPCTLEvent_Delete(event_ref);
617620
}
618621

619622
template <typename _DataType, typename _ResultType>
@@ -707,6 +710,7 @@ void dpnp_eigvals_c(const void* array_in, void* result1, size_t size)
707710
size,
708711
dep_event_vec_ref);
709712
DPCTLEvent_WaitAndThrow(event_ref);
713+
DPCTLEvent_Delete(event_ref);
710714
}
711715

712716
template <typename _DataType, typename _ResultType>
@@ -774,7 +778,7 @@ void dpnp_initval_c(void* result1, void* value, size_t size)
774778
size,
775779
dep_event_vec_ref);
776780
DPCTLEvent_WaitAndThrow(event_ref);
777-
781+
DPCTLEvent_Delete(event_ref);
778782
}
779783

780784
template <typename _DataType>
@@ -941,6 +945,7 @@ void dpnp_matmul_c(void* result_out,
941945
input2_strides,
942946
dep_event_vec_ref);
943947
DPCTLEvent_WaitAndThrow(event_ref);
948+
DPCTLEvent_Delete(event_ref);
944949
}
945950

946951
template <typename _DataType>

dpnp/backend/kernels/dpnp_krnl_linalg.cpp

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
//*****************************************************************************
2-
// Copyright (c) 2016-2020, Intel Corporation
2+
// Copyright (c) 2016-2022, Intel Corporation
33
// All rights reserved.
44
//
55
// Redistribution and use in source and binary forms, with or without
@@ -122,6 +122,7 @@ void dpnp_cholesky_c(void* array1_in, void* result1, const size_t size, const si
122122
data_size,
123123
dep_event_vec_ref);
124124
DPCTLEvent_WaitAndThrow(event_ref);
125+
DPCTLEvent_Delete(event_ref);
125126
}
126127

127128
template <typename _DataType>
@@ -263,6 +264,7 @@ void dpnp_det_c(void* array1_in, void* result1, shape_elem_type* shape, size_t n
263264
ndim,
264265
dep_event_vec_ref);
265266
DPCTLEvent_WaitAndThrow(event_ref);
267+
DPCTLEvent_Delete(event_ref);
266268
}
267269

268270
template <typename _DataType>
@@ -405,6 +407,7 @@ void dpnp_inv_c(void* array1_in, void* result1, shape_elem_type* shape, size_t n
405407
ndim,
406408
dep_event_vec_ref);
407409
DPCTLEvent_WaitAndThrow(event_ref);
410+
DPCTLEvent_Delete(event_ref);
408411
}
409412

410413
template <typename _DataType, typename _ResultType>
@@ -528,6 +531,7 @@ void dpnp_kron_c(void* array1_in,
528531
ndim,
529532
dep_event_vec_ref);
530533
DPCTLEvent_WaitAndThrow(event_ref);
534+
DPCTLEvent_Delete(event_ref);
531535
}
532536

533537
template <typename _DataType1, typename _DataType2, typename _ResultType>
@@ -616,6 +620,7 @@ void dpnp_matrix_rank_c(void* array1_in, void* result1, shape_elem_type* shape,
616620
ndim,
617621
dep_event_vec_ref);
618622
DPCTLEvent_WaitAndThrow(event_ref);
623+
DPCTLEvent_Delete(event_ref);
619624
}
620625

621626
template <typename _DataType>
@@ -753,6 +758,7 @@ void dpnp_qr_c(void* array1_in, void* result1, void* result2, void* result3, siz
753758
size_n,
754759
dep_event_vec_ref);
755760
DPCTLEvent_WaitAndThrow(event_ref);
761+
DPCTLEvent_Delete(event_ref);
756762
}
757763

758764
template <typename _InputDT, typename _ComputeDT>
@@ -852,6 +858,7 @@ void dpnp_svd_c(void* array1_in, void* result1, void* result2, void* result3, si
852858
size_n,
853859
dep_event_vec_ref);
854860
DPCTLEvent_WaitAndThrow(event_ref);
861+
DPCTLEvent_Delete(event_ref);
855862
}
856863

857864
template <typename _InputDT, typename _ComputeDT, typename _SVDT>

dpnp/dpnp_algo/dpnp_algo.pxd

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# cython: language_level=3
22
# -*- coding: utf-8 -*-
33
# *****************************************************************************
4-
# Copyright (c) 2016-2020, Intel Corporation
4+
# Copyright (c) 2016-2022, Intel Corporation
55
# All rights reserved.
66
#
77
# Redistribution and use in source and binary forms, with or without

dpnp/dpnp_iface.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,12 @@ def get_dpnp_descriptor(ext_obj, copy_when_strides=True, copy_when_nondefault_qu
219219
ext_obj_offset = 0
220220

221221
if ext_obj.strides != shape_offsets or ext_obj_offset != 0:
222-
ext_obj = array(ext_obj)
222+
# DPCTL will create a copy of array with default sycl queue
223+
# if both sycl_queue and device parameters are None.
224+
# While it is required to create the copy on the same device
225+
# to be compliant with compute follows data approach.
226+
arr_obj = unwrap_array(ext_obj)
227+
ext_obj = array(ext_obj, sycl_queue = getattr(arr_obj, "sycl_queue", None))
223228

224229
# while dpnp functions are based on DPNP_QUEUE
225230
# we need to create a copy on device associated with DPNP_QUEUE

dpnp/fft/dpnp_algo_fft.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# cython: language_level=3
22
# -*- coding: utf-8 -*-
33
# *****************************************************************************
4-
# Copyright (c) 2016-2020, Intel Corporation
4+
# Copyright (c) 2016-2022, Intel Corporation
55
# All rights reserved.
66
#
77
# Redistribution and use in source and binary forms, with or without

dpnp/fft/dpnp_iface_fft.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# distutils: language = c++
33
# -*- coding: utf-8 -*-
44
# *****************************************************************************
5-
# Copyright (c) 2016-2020, Intel Corporation
5+
# Copyright (c) 2016-2022, Intel Corporation
66
# All rights reserved.
77
#
88
# Redistribution and use in source and binary forms, with or without

dpnp/linalg/dpnp_algo_linalg.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
# cython: language_level=3
22
# -*- coding: utf-8 -*-
33
# *****************************************************************************
4-
# Copyright (c) 2016-2020, Intel Corporation
4+
# Copyright (c) 2016-2022, Intel Corporation
55
# All rights reserved.
66
#
77
# Redistribution and use in source and binary forms, with or without

dpnp/linalg/dpnp_iface_linalg.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ def cholesky(input):
9595
else:
9696
if input.dtype == dpnp.int32 or input.dtype == dpnp.int64:
9797
# TODO memory copy. needs to move into DPNPC
98-
input_ = dpnp.get_dpnp_descriptor(dpnp.astype(input, dpnp.float64))
98+
input_ = dpnp.get_dpnp_descriptor(dpnp.astype(input, dpnp.float64), copy_when_nondefault_queue=False)
9999
else:
100100
input_ = x1_desc
101101
return dpnp_cholesky(input_).get_pyobj()
@@ -277,7 +277,7 @@ def matrix_rank(input, tol=None, hermitian=False):
277277
278278
"""
279279

280-
x1_desc = dpnp.get_dpnp_descriptor(input)
280+
x1_desc = dpnp.get_dpnp_descriptor(input, copy_when_nondefault_queue=False)
281281
if x1_desc:
282282
if tol is not None:
283283
pass
@@ -362,7 +362,7 @@ def norm(x1, ord=None, axis=None, keepdims=False):
362362
Norm of the matrix or vector(s).
363363
"""
364364

365-
x1_desc = dpnp.get_dpnp_descriptor(x1)
365+
x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False)
366366
if x1_desc:
367367
if not isinstance(axis, int) and not isinstance(axis, tuple) and axis is not None:
368368
pass
@@ -464,7 +464,7 @@ def svd(x1, full_matrices=True, compute_uv=True, hermitian=False):
464464
465465
"""
466466

467-
x1_desc = dpnp.get_dpnp_descriptor(x1)
467+
x1_desc = dpnp.get_dpnp_descriptor(x1, copy_when_nondefault_queue=False)
468468
if x1_desc:
469469
if not x1_desc.ndim == 2:
470470
pass

tests/skipped_tests.tbl

Lines changed: 27 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -29,28 +29,6 @@ tests/third_party/cupy/fft_tests/test_fft.py::TestFftn_param_21_{axes=None, norm
2929
tests/third_party/cupy/fft_tests/test_fft.py::TestFftn_param_22_{axes=None, norm=None, s=None, shape=(2, 0, 5)}::test_fftn
3030
tests/third_party/cupy/fft_tests/test_fft.py::TestFftn_param_23_{axes=None, norm=None, s=None, shape=(0, 0, 5)}::test_fftn
3131

32-
tests/test_linalg.py::test_eig_arange[2-float64]
33-
tests/test_linalg.py::test_eig_arange[2-float32]
34-
tests/test_linalg.py::test_eig_arange[2-int64]
35-
tests/test_linalg.py::test_eig_arange[2-int32]
36-
tests/test_linalg.py::test_eig_arange[4-float64]
37-
tests/test_linalg.py::test_eig_arange[4-float32]
38-
tests/test_linalg.py::test_eig_arange[4-int64]
39-
tests/test_linalg.py::test_eig_arange[4-int32]
40-
tests/test_linalg.py::test_eig_arange[8-float64]
41-
tests/test_linalg.py::test_eig_arange[8-float32]
42-
tests/test_linalg.py::test_eig_arange[8-int64]
43-
tests/test_linalg.py::test_eig_arange[8-int32]
44-
tests/test_linalg.py::test_eig_arange[16-float64]
45-
tests/test_linalg.py::test_eig_arange[16-float32]
46-
tests/test_linalg.py::test_eig_arange[16-int64]
47-
tests/test_linalg.py::test_eig_arange[16-int32]
48-
tests/test_linalg.py::test_eig_arange[300-float64]
49-
tests/test_linalg.py::test_eig_arange[300-float32]
50-
tests/test_linalg.py::test_eig_arange[300-int64]
51-
tests/test_linalg.py::test_eig_arange[300-int32]
52-
tests/test_linalg.py::test_eigvals
53-
5432
tests/third_party/intel/test_zero_copy_test1.py::test_dpnp_interaction_with_dpctl_memory
5533

5634
tests/test_arraymanipulation.py::TestHstack::test_generator
@@ -104,22 +82,42 @@ tests/test_dparray.py::test_astype[[]-complex-int32]
10482
tests/test_dparray.py::test_astype[[]-complex-bool]
10583
tests/test_dparray.py::test_astype[[]-complex-bool_]
10684
tests/test_dparray.py::test_astype[[]-complex-complex]
107-
tests/test_linalg.py::test_cond[-1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
85+
86+
tests/test_linalg.py::test_cond[None-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
87+
tests/test_linalg.py::test_cond[None-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
88+
tests/test_linalg.py::test_cond[1-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
10889
tests/test_linalg.py::test_cond[1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
109-
tests/test_linalg.py::test_cond[-2-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
90+
tests/test_linalg.py::test_cond[-1-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
91+
tests/test_linalg.py::test_cond[-1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
11092
tests/test_linalg.py::test_cond[2-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
111-
tests/test_linalg.py::test_cond[-2-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
11293
tests/test_linalg.py::test_cond[2-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
94+
tests/test_linalg.py::test_cond[-2-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
95+
tests/test_linalg.py::test_cond[-2-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
96+
tests/test_linalg.py::test_cond[numpy.inf-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
97+
tests/test_linalg.py::test_cond[numpy.inf-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
98+
tests/test_linalg.py::test_cond[-numpy.inf-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
99+
tests/test_linalg.py::test_cond[-numpy.inf-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
113100
tests/test_linalg.py::test_cond["fro"-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
114101
tests/test_linalg.py::test_cond["fro"-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
115-
tests/test_linalg.py::test_cond[None-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
116-
tests/test_linalg.py::test_cond[None-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
117-
tests/test_linalg.py::test_cond[-numpy.inf-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
118-
tests/test_linalg.py::test_cond[numpy.inf-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
102+
103+
tests/test_linalg.py::test_matrix_rank[None-[0, 1]-float64]
104+
tests/test_linalg.py::test_matrix_rank[None-[0, 1]-float32]
105+
tests/test_linalg.py::test_matrix_rank[None-[0, 1]-int64]
106+
tests/test_linalg.py::test_matrix_rank[None-[0, 1]-int32]
107+
tests/test_linalg.py::test_matrix_rank[None-[[1, 2], [1, 2]]-float64]
108+
tests/test_linalg.py::test_matrix_rank[None-[[1, 2], [1, 2]]-float32]
109+
tests/test_linalg.py::test_matrix_rank[None-[[1, 2], [1, 2]]-int64]
110+
tests/test_linalg.py::test_matrix_rank[None-[[1, 2], [1, 2]]-int32]
111+
tests/test_linalg.py::test_matrix_rank[None-[[1, 2], [3, 4]]-float64]
112+
tests/test_linalg.py::test_matrix_rank[None-[[1, 2], [3, 4]]-float32]
113+
tests/test_linalg.py::test_matrix_rank[None-[[1, 2], [3, 4]]-int64]
114+
tests/test_linalg.py::test_matrix_rank[None-[[1, 2], [3, 4]]-int32]
115+
119116
tests/test_linalg.py::test_svd[(2,2)-complex128]
120117
tests/test_linalg.py::test_svd[(3,4)-complex128]
121118
tests/test_linalg.py::test_svd[(5,3)-complex128]
122119
tests/test_linalg.py::test_svd[(16,16)-complex128]
120+
123121
tests/test_mathematical.py::TestGradient::test_gradient_y1_dx[3.5-array1]
124122
tests/test_random.py::TestPermutationsTestShuffle::test_shuffle1[lambda x: (dpnp.asarray([(i, i) for i in x], [("a", int), ("b", int)]).view(dpnp.recarray))]
125123
tests/test_random.py::TestPermutationsTestShuffle::test_shuffle1[lambda x: dpnp.asarray([(i, i) for i in x], [("a", object), ("b", dpnp.int32)])]]

tests/skipped_tests_gpu.tbl

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -339,10 +339,6 @@ tests/third_party/cupy/sorting_tests/test_sort.py::TestPartition_param_2_{extern
339339
tests/third_party/cupy/statistics_tests/test_correlation.py::TestCov::test_cov_empty
340340
tests/third_party/cupy/statistics_tests/test_meanvar.py::TestMeanVar::test_external_mean_axis
341341

342-
tests/test_linalg.py::test_eig_arange[16-float64]
343-
tests/test_linalg.py::test_eig_arange[16-float32]
344-
tests/test_linalg.py::test_eig_arange[16-int64]
345-
tests/test_linalg.py::test_eig_arange[16-int32]
346342
tests/test_random.py::test_randn_normal_distribution
347343
tests/third_party/cupy/linalg_tests/test_product.py::TestProduct::test_multidim_outer
348344
tests/third_party/cupy/random_tests/test_sample.py::TestRandintDtype::test_dtype
@@ -404,6 +400,7 @@ tests/test_dparray.py::test_astype[[]-complex-int32]
404400
tests/test_dparray.py::test_astype[[]-complex-bool]
405401
tests/test_dparray.py::test_astype[[]-complex-bool_]
406402
tests/test_dparray.py::test_astype[[]-complex-complex]
403+
407404
tests/test_linalg.py::test_cond[-1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
408405
tests/test_linalg.py::test_cond[1-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
409406
tests/test_linalg.py::test_cond[-2-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
@@ -416,10 +413,20 @@ tests/test_linalg.py::test_cond[None-[[1, 0, -1], [0, 1, 0], [1, 0, 1]]]
416413
tests/test_linalg.py::test_cond[None-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
417414
tests/test_linalg.py::test_cond[-numpy.inf-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
418415
tests/test_linalg.py::test_cond[numpy.inf-[[1, 2, 3], [4, 5, 6], [7, 8, 9]]]
419-
tests/test_linalg.py::test_eig_arange[300-float32]
420-
tests/test_linalg.py::test_eig_arange[300-float64]
421-
tests/test_linalg.py::test_eig_arange[300-int32]
422-
tests/test_linalg.py::test_eig_arange[300-int64]
416+
417+
tests/test_linalg.py::test_matrix_rank[None-[0, 1]-float64]
418+
tests/test_linalg.py::test_matrix_rank[None-[0, 1]-float32]
419+
tests/test_linalg.py::test_matrix_rank[None-[0, 1]-int64]
420+
tests/test_linalg.py::test_matrix_rank[None-[0, 1]-int32]
421+
tests/test_linalg.py::test_matrix_rank[None-[[1, 2], [1, 2]]-float64]
422+
tests/test_linalg.py::test_matrix_rank[None-[[1, 2], [1, 2]]-float32]
423+
tests/test_linalg.py::test_matrix_rank[None-[[1, 2], [1, 2]]-int64]
424+
tests/test_linalg.py::test_matrix_rank[None-[[1, 2], [1, 2]]-int32]
425+
tests/test_linalg.py::test_matrix_rank[None-[[1, 2], [3, 4]]-float64]
426+
tests/test_linalg.py::test_matrix_rank[None-[[1, 2], [3, 4]]-float32]
427+
tests/test_linalg.py::test_matrix_rank[None-[[1, 2], [3, 4]]-int64]
428+
tests/test_linalg.py::test_matrix_rank[None-[[1, 2], [3, 4]]-int32]
429+
423430
tests/test_random.py::TestPermutationsTestShuffle::test_shuffle1[lambda x: (dpnp.asarray([(i, i) for i in x], [("a", int), ("b", int)]).view(dpnp.recarray))]
424431
tests/test_random.py::TestPermutationsTestShuffle::test_shuffle1[lambda x: dpnp.asarray([(i, i) for i in x], [("a", object), ("b", dpnp.int32)])]]
425432
tests/test_random.py::TestPermutationsTestShuffle::test_shuffle1[lambda x: dpnp.asarray(x).astype(dpnp.int8)]

tests/test_fft.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@
1010
def test_fft(type, norm):
1111
# 1 dim array
1212
data = numpy.arange(100, dtype=numpy.dtype(type))
13-
# doesn't work properly without dtype passed:
14-
# dpctl uses 'float32' for data with 'float64',
15-
# when device.has(sycl::aspect::fp64) is False on target host
13+
# It doesn't work properly without passing dtype explicitly:
14+
# DPCTL creates an array of 'float32' from numpy data of 'float64',
15+
# in case when device.has(sycl::aspect::fp64) is False on target host
1616
dpnp_data = dpnp.array(data, dtype=dpnp.dtype(type))
1717

1818
np_res = numpy.fft.fft(data, norm=norm)

0 commit comments

Comments
 (0)