Skip to content

Commit cf916a5

Browse files
Merge master into impl_eigvalsh
2 parents 260b171 + 44ea638 commit cf916a5

30 files changed

+1942
-1264
lines changed

.flake8

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ extend-ignore =
2626
D107,
2727
# no blank lines allowed after function docstring:
2828
D202,
29+
# 1 blank line required between summary line and description:
30+
D205,
2931
# first line should end with a period:
3032
D400,
3133
# first line should be in imperative mood:
@@ -42,7 +44,6 @@ per-file-ignores =
4244
dpnp/fft/__init__.py: F401
4345
dpnp/linalg/__init__.py: F401
4446
dpnp/random/__init__.py: F401
45-
dpnp/dpnp_iface.py: D205
4647

4748
filename = *.py, *.pyx, *.pxi, *.pxd
4849
max_line_length = 80

.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

.github/workflows/pre-commit.yml

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,19 @@ jobs:
1818
sudo ln -s /usr/bin/clang-format-12 /usr/bin/clang-format
1919
clang-format --version
2020
21-
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
22-
- uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
21+
- name: Set up pylint
22+
uses: BSFishy/pip-action@8f2d471d809dc20b6ada98c91910b6ae6243f318 # v1
23+
with:
24+
packages: |
25+
pylint
26+
27+
- name: Checkout DPNP repo
28+
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
29+
30+
- name: Set up python
31+
uses: actions/setup-python@0a5c61591373683505ea898e09a3ea4f39ef2b9c # v5.0.0
2332
with:
2433
python-version: '3.11'
25-
- uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1
34+
35+
- name: Run pre-commit checks
36+
uses: pre-commit/action@2c7b3805fd2a0fd8c1884dcaebf91fc102a13ecd # v3.0.1

.pre-commit-config.yaml

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,3 +79,19 @@ repos:
7979
rev: 3.0.0
8080
hooks:
8181
- id: shellcheck
82+
- repo: local
83+
hooks:
84+
- id: pylint
85+
name: pylint
86+
entry: pylint
87+
language: system
88+
types: [python]
89+
args:
90+
[
91+
"-rn", # Only display messages
92+
"-sn", # Don't display the score
93+
"--disable=import-error",
94+
"--disable=redefined-builtin",
95+
"--disable=unused-wildcard-import"
96+
]
97+
files: '^dpnp/dpnp_iface(|_arraycreation|_counting|_indexing|_libmath|_linearalgebra|_manipulation|_nanfunctions|_searching|_sorting|_statistics|_types).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)

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_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:

0 commit comments

Comments
 (0)