Skip to content

Commit 88b5ec9

Browse files
authored
Merge branch 'master' into update_element_wise_func
2 parents 9bbfde2 + 6c2036f commit 88b5ec9

31 files changed

+2257
-1166
lines changed

.github/workflows/conda-package.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,14 @@ env:
1818
TEST_SCOPE: >-
1919
test_arraycreation.py
2020
test_amin_amax.py
21-
test_dot.py
2221
test_dparray.py
2322
test_copy.py
2423
test_fft.py
2524
test_linalg.py
2625
test_logic.py
2726
test_manipulation.py
2827
test_mathematical.py
28+
test_product.py
2929
test_random_state.py
3030
test_sort.py
3131
test_special.py

CMakeLists.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,7 @@ FetchContent_Declare(
6363
)
6464
FetchContent_MakeAvailable(pybind11)
6565

66-
find_package(Python REQUIRED COMPONENTS Development.Module)
67-
find_package(NumPy REQUIRED)
66+
find_package(Python REQUIRED COMPONENTS Development.Module NumPy)
6867

6968
set(CYTHON_FLAGS "-t -w \"${CMAKE_SOURCE_DIR}\"")
7069
find_package(Cython REQUIRED)

SECURITY.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Security Policy
2+
3+
## Report a Vulnerability
4+
5+
Please report security issues or vulnerabilities to the [Intel® Security Center].
6+
7+
For more information on how Intel® works to resolve security issues, see
8+
[Vulnerability Handling Guidelines].
9+
10+
[Intel® Security Center]:https://www.intel.com/content/www/us/en/security-center/default.html
11+
12+
[Vulnerability Handling Guidelines]:https://www.intel.com/content/www/us/en/security-center/vulnerability-handling-guidelines.html

dpnp/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ function(build_dpnp_cython_ext _trgt _src _dest)
2121

2222
# NumPy
2323
target_compile_definitions(${_trgt} PRIVATE NPY_NO_DEPRECATED_API=NPY_1_7_API_VERSION)
24-
target_include_directories(${_trgt} PRIVATE ${NumPy_INCLUDE_DIR})
24+
target_link_libraries(${_trgt} PRIVATE Python::NumPy)
2525

2626
# Dpctl
2727
target_include_directories(${_trgt} PRIVATE ${Dpctl_INCLUDE_DIR})

dpnp/backend/include/dpnp_iface_fptr.hpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -105,8 +105,6 @@ enum class DPNPFuncName : size_t
105105
DPNP_FN_COUNT_NONZERO, /**< Used in numpy.count_nonzero() impl */
106106
DPNP_FN_COV, /**< Used in numpy.cov() impl */
107107
DPNP_FN_CROSS, /**< Used in numpy.cross() impl */
108-
DPNP_FN_CROSS_EXT, /**< Used in numpy.cross() impl, requires extra
109-
parameters */
110108
DPNP_FN_CUMPROD, /**< Used in numpy.cumprod() impl */
111109
DPNP_FN_CUMPROD_EXT, /**< Used in numpy.cumprod() impl, requires extra
112110
parameters */

dpnp/backend/kernels/dpnp_krnl_mathematical.cpp

Lines changed: 0 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -311,23 +311,6 @@ void (*dpnp_cross_default_c)(void *,
311311
const size_t *) =
312312
dpnp_cross_c<_DataType_output, _DataType_input1, _DataType_input2>;
313313

314-
template <typename _DataType_output,
315-
typename _DataType_input1,
316-
typename _DataType_input2>
317-
DPCTLSyclEventRef (*dpnp_cross_ext_c)(DPCTLSyclQueueRef,
318-
void *,
319-
const void *,
320-
const size_t,
321-
const shape_elem_type *,
322-
const size_t,
323-
const void *,
324-
const size_t,
325-
const shape_elem_type *,
326-
const size_t,
327-
const size_t *,
328-
const DPCTLEventVectorRef) =
329-
dpnp_cross_c<_DataType_output, _DataType_input1, _DataType_input2>;
330-
331314
template <typename _KernelNameSpecialization1,
332315
typename _KernelNameSpecialization2>
333316
class dpnp_cumprod_c_kernel;
@@ -1116,31 +1099,6 @@ DPCTLSyclEventRef (*dpnp_trapz_ext_c)(DPCTLSyclQueueRef,
11161099
const DPCTLEventVectorRef) =
11171100
dpnp_trapz_c<_DataType_input1, _DataType_input2, _DataType_output>;
11181101

1119-
template <DPNPFuncType FT1, DPNPFuncType... FTs>
1120-
static void func_map_elemwise_2arg_3type_core(func_map_t &fmap)
1121-
{
1122-
((fmap[DPNPFuncName::DPNP_FN_CROSS_EXT][FT1][FTs] =
1123-
{get_floating_res_type<FT1, FTs, std::true_type, std::true_type>(),
1124-
(void *)dpnp_cross_ext_c<
1125-
func_type_map_t::find_type<get_floating_res_type<
1126-
FT1, FTs, std::true_type, std::true_type>()>,
1127-
func_type_map_t::find_type<FT1>,
1128-
func_type_map_t::find_type<FTs>>,
1129-
get_floating_res_type<FT1, FTs, std::false_type, std::true_type>(),
1130-
(void *)dpnp_cross_ext_c<
1131-
func_type_map_t::find_type<get_floating_res_type<
1132-
FT1, FTs, std::false_type, std::true_type>()>,
1133-
func_type_map_t::find_type<FT1>,
1134-
func_type_map_t::find_type<FTs>>}),
1135-
...);
1136-
}
1137-
1138-
template <DPNPFuncType... FTs>
1139-
static void func_map_elemwise_2arg_3type_helper(func_map_t &fmap)
1140-
{
1141-
((func_map_elemwise_2arg_3type_core<FTs, FTs...>(fmap)), ...);
1142-
}
1143-
11441102
void func_map_init_mathematical(func_map_t &fmap)
11451103
{
11461104
fmap[DPNPFuncName::DPNP_FN_ABSOLUTE][eft_INT][eft_INT] = {
@@ -1402,8 +1360,5 @@ void func_map_init_mathematical(func_map_t &fmap)
14021360
fmap[DPNPFuncName::DPNP_FN_TRAPZ_EXT][eft_DBL][eft_DBL] = {
14031361
eft_DBL, (void *)dpnp_trapz_ext_c<double, double, double>};
14041362

1405-
func_map_elemwise_2arg_3type_helper<eft_INT, eft_LNG, eft_FLT, eft_DBL>(
1406-
fmap);
1407-
14081363
return;
14091364
}

dpnp/dpnp_algo/dpnp_algo.pxd

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,6 @@ cdef extern from "dpnp_iface_fptr.hpp" namespace "DPNPFuncName": # need this na
4242
DPNP_FN_COPY_EXT
4343
DPNP_FN_CORRELATE
4444
DPNP_FN_CORRELATE_EXT
45-
DPNP_FN_CROSS
46-
DPNP_FN_CROSS_EXT
4745
DPNP_FN_CUMPROD
4846
DPNP_FN_CUMPROD_EXT
4947
DPNP_FN_CUMSUM

dpnp/dpnp_algo/dpnp_algo.pyx

Lines changed: 0 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -278,77 +278,6 @@ cdef utils.dpnp_descriptor call_fptr_1in_1out_strides(DPNPFuncName fptr_name,
278278
return result
279279

280280

281-
cdef utils.dpnp_descriptor call_fptr_2in_1out(DPNPFuncName fptr_name,
282-
utils.dpnp_descriptor x1_obj,
283-
utils.dpnp_descriptor x2_obj,
284-
object dtype=None,
285-
utils.dpnp_descriptor out=None,
286-
object where=True,
287-
func_name=None):
288-
289-
# Convert type (x1_obj.dtype) to C enum DPNPFuncType
290-
cdef DPNPFuncType x1_c_type = dpnp_dtype_to_DPNPFuncType(x1_obj.dtype)
291-
cdef DPNPFuncType x2_c_type = dpnp_dtype_to_DPNPFuncType(x2_obj.dtype)
292-
293-
# get the FPTR data structure
294-
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(fptr_name, x1_c_type, x2_c_type)
295-
296-
result_sycl_device, result_usm_type, result_sycl_queue = utils.get_common_usm_allocation(x1_obj, x2_obj)
297-
298-
# get FPTR function and return type
299-
cdef (DPNPFuncType, void *) ret_type_and_func = utils.get_ret_type_and_func(kernel_data,
300-
result_sycl_device.has_aspect_fp64)
301-
cdef DPNPFuncType return_type = ret_type_and_func[0]
302-
cdef fptr_2in_1out_t func = < fptr_2in_1out_t > ret_type_and_func[1]
303-
304-
result_type = dpnp_DPNPFuncType_to_dtype( < size_t > return_type)
305-
306-
# Create result array
307-
cdef shape_type_c x1_shape = x1_obj.shape
308-
cdef shape_type_c x2_shape = x2_obj.shape
309-
cdef shape_type_c result_shape = utils.get_common_shape(x1_shape, x2_shape)
310-
cdef utils.dpnp_descriptor result
311-
312-
if out is None:
313-
""" Create result array with type given by FPTR data """
314-
result = utils.create_output_descriptor(result_shape,
315-
return_type,
316-
None,
317-
device=result_sycl_device,
318-
usm_type=result_usm_type,
319-
sycl_queue=result_sycl_queue)
320-
else:
321-
if out.dtype != result_type:
322-
utils.checker_throw_value_error(func_name, 'out.dtype', out.dtype, result_type)
323-
if out.shape != result_shape:
324-
utils.checker_throw_value_error(func_name, 'out.shape', out.shape, result_shape)
325-
326-
result = out
327-
328-
utils.get_common_usm_allocation(x1_obj, result) # check USM allocation is common
329-
330-
cdef c_dpctl.SyclQueue q = <c_dpctl.SyclQueue> result_sycl_queue
331-
cdef c_dpctl.DPCTLSyclQueueRef q_ref = q.get_queue_ref()
332-
333-
""" Call FPTR function """
334-
cdef c_dpctl.DPCTLSyclEventRef event_ref = func(q_ref,
335-
result.get_data(),
336-
x1_obj.get_data(),
337-
x1_obj.size,
338-
x1_shape.data(),
339-
x1_shape.size(),
340-
x2_obj.get_data(),
341-
x2_obj.size,
342-
x2_shape.data(),
343-
x2_shape.size(),
344-
NULL,
345-
NULL) # dep_events_ref)
346-
347-
with nogil: c_dpctl.DPCTLEvent_WaitAndThrow(event_ref)
348-
c_dpctl.DPCTLEvent_Delete(event_ref)
349-
350-
return result
351-
352281
cdef utils.dpnp_descriptor call_fptr_2in_1out_strides(DPNPFuncName fptr_name,
353282
utils.dpnp_descriptor x1_obj,
354283
utils.dpnp_descriptor x2_obj,

dpnp/dpnp_algo/dpnp_algo_linearalgebra.pxi

Lines changed: 0 additions & 75 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ and the rest of the library
3636
# NO IMPORTs here. All imports must be placed into main "dpnp_algo.pyx" file
3737

3838
__all__ += [
39-
"dpnp_inner",
4039
"dpnp_kron",
4140
]
4241

@@ -48,80 +47,6 @@ ctypedef c_dpctl.DPCTLSyclEventRef(*fptr_2in_1out_shapes_t)(c_dpctl.DPCTLSyclQue
4847
const c_dpctl.DPCTLEventVectorRef)
4948

5049

51-
cpdef utils.dpnp_descriptor dpnp_inner(dpnp_descriptor array1, dpnp_descriptor array2):
52-
result_type = numpy.promote_types(array1.dtype, array1.dtype)
53-
54-
assert(len(array1.shape) == len(array2.shape))
55-
56-
cdef shape_type_c array1_no_last_axes = array1.shape[:-1]
57-
cdef shape_type_c array2_no_last_axes = array2.shape[:-1]
58-
59-
cdef shape_type_c result_shape = array1_no_last_axes
60-
result_shape.insert(result_shape.end(), array2_no_last_axes.begin(), array2_no_last_axes.end())
61-
62-
result_sycl_device, result_usm_type, result_sycl_queue = utils.get_common_usm_allocation(array1, array2)
63-
64-
# create result array with type given by FPTR data
65-
cdef utils.dpnp_descriptor result = utils_py.create_output_descriptor_py(result_shape,
66-
result_type,
67-
None,
68-
device=result_sycl_device,
69-
usm_type=result_usm_type,
70-
sycl_queue=result_sycl_queue)
71-
72-
# calculate input arrays offsets
73-
cdef shape_type_c array1_offsets = [1] * len(array1.shape)
74-
cdef shape_type_c array2_offsets = [1] * len(array2.shape)
75-
cdef size_t acc1 = 1
76-
cdef size_t acc2 = 1
77-
for axis in range(len(array1.shape) - 1, -1, -1):
78-
array1_offsets[axis] = acc1
79-
array2_offsets[axis] = acc2
80-
acc1 *= array1.shape[axis]
81-
acc2 *= array2.shape[axis]
82-
83-
cdef shape_type_c result_shape_offsets = [1] * len(result.shape)
84-
acc = 1
85-
for i in range(len(result.shape) - 1, -1, -1):
86-
result_shape_offsets[i] = acc
87-
acc *= result.shape[i]
88-
89-
cdef shape_type_c xyz
90-
cdef size_t array1_lin_index_base
91-
cdef size_t array2_lin_index_base
92-
cdef size_t axis2
93-
cdef long remainder
94-
cdef long quotient
95-
96-
result_flatiter = result.get_pyobj().flat
97-
array1_flatiter = array1.get_pyobj().flat
98-
array2_flatiter = array2.get_pyobj().flat
99-
100-
for idx1 in range(result.size):
101-
# reconstruct x,y,z from linear index
102-
xyz.clear()
103-
remainder = idx1
104-
for i in result_shape_offsets:
105-
quotient, remainder = divmod(remainder, i)
106-
xyz.push_back(quotient)
107-
108-
# calculate linear base input index
109-
array1_lin_index_base = 0
110-
array2_lin_index_base = 0
111-
for axis in range(len(array1_offsets) - 1):
112-
axis2 = axis + (len(xyz) / 2)
113-
array1_lin_index_base += array1_offsets[axis] * xyz[axis]
114-
array2_lin_index_base += array2_offsets[axis] * xyz[axis2]
115-
116-
# do inner product
117-
result_flatiter[idx1] = 0
118-
for idx2 in range(array1.shape[-1]):
119-
result_flatiter[idx1] += array1_flatiter[array1_lin_index_base + idx2] * \
120-
array2_flatiter[array2_lin_index_base + idx2]
121-
122-
return result
123-
124-
12550
cpdef utils.dpnp_descriptor dpnp_kron(dpnp_descriptor in_array1, dpnp_descriptor in_array2):
12651
cdef size_t ndim = max(in_array1.ndim, in_array2.ndim)
12752

dpnp/dpnp_algo/dpnp_algo_mathematical.pxi

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ and the rest of the library
3636
# NO IMPORTs here. All imports must be placed into main "dpnp_algo.pyx" file
3737

3838
__all__ += [
39-
"dpnp_cross",
4039
"dpnp_cumprod",
4140
"dpnp_cumsum",
4241
"dpnp_ediff1d",
@@ -60,14 +59,6 @@ ctypedef c_dpctl.DPCTLSyclEventRef(*ftpr_custom_trapz_2in_1out_with_2size_t)(c_d
6059
const c_dpctl.DPCTLEventVectorRef)
6160

6261

63-
cpdef utils.dpnp_descriptor dpnp_cross(utils.dpnp_descriptor x1_obj,
64-
utils.dpnp_descriptor x2_obj,
65-
object dtype=None,
66-
utils.dpnp_descriptor out=None,
67-
object where=True):
68-
return call_fptr_2in_1out(DPNP_FN_CROSS_EXT, x1_obj, x2_obj, dtype, out, where)
69-
70-
7162
cpdef utils.dpnp_descriptor dpnp_cumprod(utils.dpnp_descriptor x1):
7263
# instead of x1.shape, (x1.size, ) is passed to the function
7364
# due to the following:

dpnp/dpnp_array.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -540,7 +540,7 @@ def astype(self, dtype, order="K", casting="unsafe", subok=True, copy=True):
540540
Array data type casting.
541541
dtype : dtype
542542
Target data type.
543-
order : {'C', 'F', 'A', 'K'}
543+
order : {"C", "F", "A", "K"}, optional
544544
Row-major (C-style) or column-major (Fortran-style) order.
545545
When ``order`` is 'A', it uses 'F' if ``a`` is column-major and uses 'C' otherwise.
546546
And when ``order`` is 'K', it keeps strides as closely as possible.

dpnp/dpnp_iface.py

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
"array_equal",
5757
"asnumpy",
5858
"astype",
59+
"check_limitations",
5960
"check_supported_arrays_type",
6061
"convert_single_elem_array_to_scalar",
6162
"default_float_type",
@@ -232,6 +233,58 @@ def astype(x1, dtype, order="K", casting="unsafe", copy=True):
232233
return dpnp_array._create_from_usm_ndarray(array_obj)
233234

234235

236+
def check_limitations(
237+
order=None, subok=False, like=None, initial=None, where=True
238+
):
239+
"""
240+
Checking limitation kwargs for their supported values.
241+
242+
Parameter `order` is only supported with values ``"C"``, ``"F"``
243+
and ``None``.
244+
Parameter `subok` is only supported with default value ``False``.
245+
Parameter `like` is only supported with default value ``None``.
246+
Parameter `initial` is only supported with default value ``None``.
247+
Parameter `where` is only supported with default value ``True``.
248+
249+
Raises
250+
------
251+
NotImplementedError
252+
If any input kwargs is of unsupported value.
253+
254+
"""
255+
256+
if order in ("A", "a", "K", "k"):
257+
raise NotImplementedError(
258+
"Keyword argument `order` is supported only with "
259+
f"values ``'C'`` and ``'F'``, but got {order}"
260+
)
261+
if order not in ("C", "c", "F", "f", None):
262+
raise ValueError(
263+
"Unrecognized `order` keyword value, expecting "
264+
f"``'C'`` or ``'F'``, but got {order}"
265+
)
266+
if like is not None:
267+
raise NotImplementedError(
268+
"Keyword argument `like` is supported only with "
269+
f"default value ``None``, but got {like}"
270+
)
271+
if subok is not False:
272+
raise NotImplementedError(
273+
"Keyword argument `subok` is supported only with "
274+
f"default value ``False``, but got {subok}"
275+
)
276+
if initial is not None:
277+
raise NotImplementedError(
278+
"Keyword argument `initial` is only supported with "
279+
f"default value ``None``, but got {initial}"
280+
)
281+
if where is not True:
282+
raise NotImplementedError(
283+
"Keyword argument `where` is supported only with "
284+
f"default value ``True``, but got {where}"
285+
)
286+
287+
235288
def check_supported_arrays_type(*arrays, scalar_type=False, all_scalars=False):
236289
"""
237290
Return ``True`` if each array has either type of scalar,

0 commit comments

Comments
 (0)