Skip to content

Commit afac000

Browse files
authored
Merge 99f94c6 into 28d3348
2 parents 28d3348 + 99f94c6 commit afac000

20 files changed

+999
-684
lines changed

dpnp/backend/include/dpnp_iface_fptr.hpp

Lines changed: 15 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -216,8 +216,6 @@ enum class DPNPFuncName : size_t
216216
DPNP_FN_MULTIPLY_EXT, /**< Used in numpy.multiply() impl, requires extra
217217
parameters */
218218
DPNP_FN_NANVAR, /**< Used in numpy.nanvar() impl */
219-
DPNP_FN_NANVAR_EXT, /**< Used in numpy.nanvar() impl, requires extra
220-
parameters */
221219
DPNP_FN_NEGATIVE, /**< Used in numpy.negative() impl */
222220
DPNP_FN_NONZERO, /**< Used in numpy.nonzero() impl */
223221
DPNP_FN_ONES, /**< Used in numpy.ones() impl */
@@ -374,8 +372,7 @@ enum class DPNPFuncName : size_t
374372
*/
375373
DPNP_FN_SQUARE, /**< Used in numpy.square() impl */
376374
DPNP_FN_STD, /**< Used in numpy.std() impl */
377-
DPNP_FN_STD_EXT, /**< Used in numpy.std() impl, requires extra parameters */
378-
DPNP_FN_SUBTRACT, /**< Used in numpy.subtract() impl */
375+
DPNP_FN_SUBTRACT, /**< Used in numpy.subtract() impl */
379376
DPNP_FN_SUBTRACT_EXT, /**< Used in numpy.subtract() impl, requires extra
380377
parameters */
381378
DPNP_FN_SUM, /**< Used in numpy.sum() impl */
@@ -386,21 +383,20 @@ enum class DPNPFuncName : size_t
386383
DPNP_FN_TAKE, /**< Used in numpy.take() impl */
387384
DPNP_FN_TAN, /**< Used in numpy.tan() impl */
388385
DPNP_FN_TANH, /**< Used in numpy.tanh() impl */
389-
DPNP_FN_TRANSPOSE, /**< Used in numpy.transpose() impl */
390-
DPNP_FN_TRACE, /**< Used in numpy.trace() impl */
391-
DPNP_FN_TRACE_EXT, /**< Used in numpy.trace() impl, requires extra
392-
parameters */
393-
DPNP_FN_TRAPZ, /**< Used in numpy.trapz() impl */
394-
DPNP_FN_TRAPZ_EXT, /**< Used in numpy.trapz() impl, requires extra
395-
parameters */
396-
DPNP_FN_TRI, /**< Used in numpy.tri() impl */
397-
DPNP_FN_TRIL, /**< Used in numpy.tril() impl */
398-
DPNP_FN_TRIU, /**< Used in numpy.triu() impl */
399-
DPNP_FN_TRUNC, /**< Used in numpy.trunc() impl */
400-
DPNP_FN_VANDER, /**< Used in numpy.vander() impl */
401-
DPNP_FN_VAR, /**< Used in numpy.var() impl */
402-
DPNP_FN_VAR_EXT, /**< Used in numpy.var() impl, requires extra parameters */
403-
DPNP_FN_ZEROS, /**< Used in numpy.zeros() impl */
386+
DPNP_FN_TRANSPOSE, /**< Used in numpy.transpose() impl */
387+
DPNP_FN_TRACE, /**< Used in numpy.trace() impl */
388+
DPNP_FN_TRACE_EXT, /**< Used in numpy.trace() impl, requires extra
389+
parameters */
390+
DPNP_FN_TRAPZ, /**< Used in numpy.trapz() impl */
391+
DPNP_FN_TRAPZ_EXT, /**< Used in numpy.trapz() impl, requires extra
392+
parameters */
393+
DPNP_FN_TRI, /**< Used in numpy.tri() impl */
394+
DPNP_FN_TRIL, /**< Used in numpy.tril() impl */
395+
DPNP_FN_TRIU, /**< Used in numpy.triu() impl */
396+
DPNP_FN_TRUNC, /**< Used in numpy.trunc() impl */
397+
DPNP_FN_VANDER, /**< Used in numpy.vander() impl */
398+
DPNP_FN_VAR, /**< Used in numpy.var() impl */
399+
DPNP_FN_ZEROS, /**< Used in numpy.zeros() impl */
404400
DPNP_FN_ZEROS_LIKE, /**< Used in numpy.zeros_like() impl */
405401
DPNP_FN_LAST, /**< The latest element of the enumeration */
406402
};

dpnp/backend/kernels/dpnp_krnl_statistics.cpp

Lines changed: 0 additions & 61 deletions
Original file line numberDiff line numberDiff line change
@@ -939,16 +939,6 @@ template <typename _DataType>
939939
void (*dpnp_nanvar_default_c)(void *, void *, void *, const size_t, size_t) =
940940
dpnp_nanvar_c<_DataType>;
941941

942-
template <typename _DataType>
943-
DPCTLSyclEventRef (*dpnp_nanvar_ext_c)(DPCTLSyclQueueRef,
944-
void *,
945-
void *,
946-
void *,
947-
const size_t,
948-
size_t,
949-
const DPCTLEventVectorRef) =
950-
dpnp_nanvar_c<_DataType>;
951-
952942
template <typename _DataType, typename _ResultType>
953943
DPCTLSyclEventRef dpnp_std_c(DPCTLSyclQueueRef q_ref,
954944
void *array1_in,
@@ -1039,18 +1029,6 @@ void (*dpnp_std_default_c)(void *,
10391029
size_t,
10401030
size_t) = dpnp_std_c<_DataType, _ResultType>;
10411031

1042-
template <typename _DataType, typename _ResultType>
1043-
DPCTLSyclEventRef (*dpnp_std_ext_c)(DPCTLSyclQueueRef,
1044-
void *,
1045-
void *,
1046-
const shape_elem_type *,
1047-
size_t,
1048-
const shape_elem_type *,
1049-
size_t,
1050-
size_t,
1051-
const DPCTLEventVectorRef) =
1052-
dpnp_std_c<_DataType, _ResultType>;
1053-
10541032
template <typename _DataType, typename _ResultType>
10551033
class dpnp_var_c_kernel;
10561034

@@ -1150,18 +1128,6 @@ void (*dpnp_var_default_c)(void *,
11501128
size_t,
11511129
size_t) = dpnp_var_c<_DataType, _ResultType>;
11521130

1153-
template <typename _DataType, typename _ResultType>
1154-
DPCTLSyclEventRef (*dpnp_var_ext_c)(DPCTLSyclQueueRef,
1155-
void *,
1156-
void *,
1157-
const shape_elem_type *,
1158-
size_t,
1159-
const shape_elem_type *,
1160-
size_t,
1161-
size_t,
1162-
const DPCTLEventVectorRef) =
1163-
dpnp_var_c<_DataType, _ResultType>;
1164-
11651131
void func_map_init_statistics(func_map_t &fmap)
11661132
{
11671133
fmap[DPNPFuncName::DPNP_FN_CORRELATE][eft_INT][eft_INT] = {
@@ -1316,15 +1282,6 @@ void func_map_init_statistics(func_map_t &fmap)
13161282
fmap[DPNPFuncName::DPNP_FN_NANVAR][eft_DBL][eft_DBL] = {
13171283
eft_DBL, (void *)dpnp_nanvar_default_c<double>};
13181284

1319-
fmap[DPNPFuncName::DPNP_FN_NANVAR_EXT][eft_INT][eft_INT] = {
1320-
eft_INT, (void *)dpnp_nanvar_ext_c<int32_t>};
1321-
fmap[DPNPFuncName::DPNP_FN_NANVAR_EXT][eft_LNG][eft_LNG] = {
1322-
eft_LNG, (void *)dpnp_nanvar_ext_c<int64_t>};
1323-
fmap[DPNPFuncName::DPNP_FN_NANVAR_EXT][eft_FLT][eft_FLT] = {
1324-
eft_FLT, (void *)dpnp_nanvar_ext_c<float>};
1325-
fmap[DPNPFuncName::DPNP_FN_NANVAR_EXT][eft_DBL][eft_DBL] = {
1326-
eft_DBL, (void *)dpnp_nanvar_ext_c<double>};
1327-
13281285
fmap[DPNPFuncName::DPNP_FN_STD][eft_INT][eft_INT] = {
13291286
eft_DBL, (void *)dpnp_std_default_c<int32_t, double>};
13301287
fmap[DPNPFuncName::DPNP_FN_STD][eft_LNG][eft_LNG] = {
@@ -1334,15 +1291,6 @@ void func_map_init_statistics(func_map_t &fmap)
13341291
fmap[DPNPFuncName::DPNP_FN_STD][eft_DBL][eft_DBL] = {
13351292
eft_DBL, (void *)dpnp_std_default_c<double, double>};
13361293

1337-
fmap[DPNPFuncName::DPNP_FN_STD_EXT][eft_INT][eft_INT] = {
1338-
eft_DBL, (void *)dpnp_std_ext_c<int32_t, double>};
1339-
fmap[DPNPFuncName::DPNP_FN_STD_EXT][eft_LNG][eft_LNG] = {
1340-
eft_DBL, (void *)dpnp_std_ext_c<int64_t, double>};
1341-
fmap[DPNPFuncName::DPNP_FN_STD_EXT][eft_FLT][eft_FLT] = {
1342-
eft_FLT, (void *)dpnp_std_ext_c<float, float>};
1343-
fmap[DPNPFuncName::DPNP_FN_STD_EXT][eft_DBL][eft_DBL] = {
1344-
eft_DBL, (void *)dpnp_std_ext_c<double, double>};
1345-
13461294
fmap[DPNPFuncName::DPNP_FN_VAR][eft_INT][eft_INT] = {
13471295
eft_DBL, (void *)dpnp_var_default_c<int32_t, double>};
13481296
fmap[DPNPFuncName::DPNP_FN_VAR][eft_LNG][eft_LNG] = {
@@ -1352,14 +1300,5 @@ void func_map_init_statistics(func_map_t &fmap)
13521300
fmap[DPNPFuncName::DPNP_FN_VAR][eft_DBL][eft_DBL] = {
13531301
eft_DBL, (void *)dpnp_var_default_c<double, double>};
13541302

1355-
fmap[DPNPFuncName::DPNP_FN_VAR_EXT][eft_INT][eft_INT] = {
1356-
eft_DBL, (void *)dpnp_var_ext_c<int32_t, double>};
1357-
fmap[DPNPFuncName::DPNP_FN_VAR_EXT][eft_LNG][eft_LNG] = {
1358-
eft_DBL, (void *)dpnp_var_ext_c<int64_t, double>};
1359-
fmap[DPNPFuncName::DPNP_FN_VAR_EXT][eft_FLT][eft_FLT] = {
1360-
eft_FLT, (void *)dpnp_var_ext_c<float, float>};
1361-
fmap[DPNPFuncName::DPNP_FN_VAR_EXT][eft_DBL][eft_DBL] = {
1362-
eft_DBL, (void *)dpnp_var_ext_c<double, double>};
1363-
13641303
return;
13651304
}

dpnp/dpnp_algo/dpnp_algo.pxd

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -100,8 +100,6 @@ cdef extern from "dpnp_iface_fptr.hpp" namespace "DPNPFuncName": # need this na
100100
DPNP_FN_MINIMUM_EXT
101101
DPNP_FN_MODF
102102
DPNP_FN_MODF_EXT
103-
DPNP_FN_NANVAR
104-
DPNP_FN_NANVAR_EXT
105103
DPNP_FN_NONZERO
106104
DPNP_FN_ONES
107105
DPNP_FN_ONES_LIKE
@@ -187,8 +185,6 @@ cdef extern from "dpnp_iface_fptr.hpp" namespace "DPNPFuncName": # need this na
187185
DPNP_FN_SEARCHSORTED_EXT
188186
DPNP_FN_SORT
189187
DPNP_FN_SORT_EXT
190-
DPNP_FN_STD
191-
DPNP_FN_STD_EXT
192188
DPNP_FN_SUM
193189
DPNP_FN_SUM_EXT
194190
DPNP_FN_SVD
@@ -202,8 +198,6 @@ cdef extern from "dpnp_iface_fptr.hpp" namespace "DPNPFuncName": # need this na
202198
DPNP_FN_TRIL_EXT
203199
DPNP_FN_TRIU
204200
DPNP_FN_TRIU_EXT
205-
DPNP_FN_VAR
206-
DPNP_FN_VAR_EXT
207201
DPNP_FN_ZEROS
208202
DPNP_FN_ZEROS_LIKE
209203

dpnp/dpnp_algo/dpnp_algo_statistics.pxi

Lines changed: 0 additions & 113 deletions
Original file line numberDiff line numberDiff line change
@@ -39,78 +39,15 @@ __all__ += [
3939
"dpnp_average",
4040
"dpnp_correlate",
4141
"dpnp_median",
42-
"dpnp_nanvar",
43-
"dpnp_std",
44-
"dpnp_var",
4542
]
4643

4744

48-
# C function pointer to the C library template functions
49-
ctypedef c_dpctl.DPCTLSyclEventRef(*fptr_custom_cov_1in_1out_t)(c_dpctl.DPCTLSyclQueueRef,
50-
void *, void * , size_t, size_t,
51-
const c_dpctl.DPCTLEventVectorRef)
52-
ctypedef c_dpctl.DPCTLSyclEventRef(*fptr_custom_nanvar_t)(c_dpctl.DPCTLSyclQueueRef,
53-
void *, void * , void * , size_t, size_t,
54-
const c_dpctl.DPCTLEventVectorRef)
55-
ctypedef c_dpctl.DPCTLSyclEventRef(*fptr_custom_std_var_1in_1out_t)(c_dpctl.DPCTLSyclQueueRef,
56-
void *, void * , shape_elem_type * , size_t,
57-
shape_elem_type * , size_t, size_t,
58-
const c_dpctl.DPCTLEventVectorRef)
59-
6045
# C function pointer to the C library template functions
6146
ctypedef c_dpctl.DPCTLSyclEventRef(*custom_statistic_1in_1out_func_ptr_t)(c_dpctl.DPCTLSyclQueueRef,
6247
void *, void * , shape_elem_type * , size_t,
6348
shape_elem_type * , size_t,
6449
const c_dpctl.DPCTLEventVectorRef)
6550

66-
cdef utils.dpnp_descriptor call_fptr_custom_std_var_1in_1out(DPNPFuncName fptr_name, utils.dpnp_descriptor x1, ddof):
67-
cdef shape_type_c x1_shape = x1.shape
68-
69-
""" Convert string type names (array.dtype) to C enum DPNPFuncType """
70-
cdef DPNPFuncType param_type = dpnp_dtype_to_DPNPFuncType(x1.dtype)
71-
72-
""" get the FPTR data structure """
73-
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(fptr_name, param_type, DPNP_FT_NONE)
74-
75-
x1_obj = x1.get_array()
76-
77-
# create result array with type given by FPTR data
78-
cdef shape_type_c result_shape = (1,)
79-
cdef utils.dpnp_descriptor result = utils.create_output_descriptor(result_shape,
80-
kernel_data.return_type,
81-
None,
82-
device=x1_obj.sycl_device,
83-
usm_type=x1_obj.usm_type,
84-
sycl_queue=x1_obj.sycl_queue)
85-
86-
result_sycl_queue = result.get_array().sycl_queue
87-
88-
cdef c_dpctl.SyclQueue q = <c_dpctl.SyclQueue> result_sycl_queue
89-
cdef c_dpctl.DPCTLSyclQueueRef q_ref = q.get_queue_ref()
90-
91-
cdef fptr_custom_std_var_1in_1out_t func = <fptr_custom_std_var_1in_1out_t > kernel_data.ptr
92-
93-
# stub for interface support
94-
cdef shape_type_c axis
95-
cdef Py_ssize_t axis_size = 0
96-
97-
""" Call FPTR function """
98-
cdef c_dpctl.DPCTLSyclEventRef event_ref = func(q_ref,
99-
x1.get_data(),
100-
result.get_data(),
101-
x1_shape.data(),
102-
x1.ndim,
103-
axis.data(),
104-
axis_size,
105-
ddof,
106-
NULL) # dep_events_ref
107-
108-
with nogil: c_dpctl.DPCTLEvent_WaitAndThrow(event_ref)
109-
c_dpctl.DPCTLEvent_Delete(event_ref)
110-
111-
112-
return result
113-
11451

11552
cpdef dpnp_average(utils.dpnp_descriptor x1):
11653
array_sum = dpnp_sum(x1).get_pyobj()
@@ -207,53 +144,3 @@ cpdef utils.dpnp_descriptor dpnp_median(utils.dpnp_descriptor array1):
207144
c_dpctl.DPCTLEvent_Delete(event_ref)
208145

209146
return result
210-
211-
212-
cpdef utils.dpnp_descriptor dpnp_nanvar(utils.dpnp_descriptor arr, ddof):
213-
# dpnp_isnan does not support USM array as input in comparison to dpnp.isnan
214-
cdef utils.dpnp_descriptor mask_arr = dpnp.get_dpnp_descriptor(dpnp.isnan(arr.get_pyobj()),
215-
copy_when_nondefault_queue=False)
216-
n = dpnp.count_nonzero(mask_arr.get_pyobj())
217-
res_size = int(arr.size - n)
218-
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(arr.dtype)
219-
220-
cdef DPNPFuncData kernel_data = get_dpnp_function_ptr(DPNP_FN_NANVAR_EXT, param1_type, param1_type)
221-
222-
arr_obj = arr.get_array()
223-
224-
# create result array with type given by FPTR data
225-
cdef shape_type_c result_shape = utils._object_to_tuple(res_size)
226-
cdef utils.dpnp_descriptor result = utils.create_output_descriptor(result_shape,
227-
kernel_data.return_type,
228-
None,
229-
device=arr_obj.sycl_device,
230-
usm_type=arr_obj.usm_type,
231-
sycl_queue=arr_obj.sycl_queue)
232-
233-
result_sycl_queue = result.get_array().sycl_queue
234-
235-
cdef c_dpctl.SyclQueue q = <c_dpctl.SyclQueue> result_sycl_queue
236-
cdef c_dpctl.DPCTLSyclQueueRef q_ref = q.get_queue_ref()
237-
238-
cdef fptr_custom_nanvar_t func = <fptr_custom_nanvar_t > kernel_data.ptr
239-
240-
cdef c_dpctl.DPCTLSyclEventRef event_ref = func(q_ref,
241-
arr.get_data(),
242-
mask_arr.get_data(),
243-
result.get_data(),
244-
result.size,
245-
arr.size,
246-
NULL) # dep_events_ref
247-
248-
with nogil: c_dpctl.DPCTLEvent_WaitAndThrow(event_ref)
249-
c_dpctl.DPCTLEvent_Delete(event_ref)
250-
251-
return call_fptr_custom_std_var_1in_1out(DPNP_FN_VAR_EXT, result, ddof)
252-
253-
254-
cpdef utils.dpnp_descriptor dpnp_std(utils.dpnp_descriptor a, size_t ddof):
255-
return call_fptr_custom_std_var_1in_1out(DPNP_FN_STD_EXT, a, ddof)
256-
257-
258-
cpdef utils.dpnp_descriptor dpnp_var(utils.dpnp_descriptor a, size_t ddof):
259-
return call_fptr_custom_std_var_1in_1out(DPNP_FN_VAR_EXT, a, ddof)

dpnp/dpnp_array.py

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1167,15 +1167,23 @@ def squeeze(self, axis=None):
11671167

11681168
return dpnp.squeeze(self, axis)
11691169

1170-
def std(self, axis=None, dtype=None, out=None, ddof=0, keepdims=False):
1171-
"""Returns the variance of the array elements, along given axis.
1172-
1173-
.. seealso::
1174-
:obj:`dpnp.var` for full documentation,
1170+
def std(
1171+
self,
1172+
axis=None,
1173+
dtype=None,
1174+
out=None,
1175+
ddof=0,
1176+
keepdims=False,
1177+
*,
1178+
where=True,
1179+
):
1180+
"""
1181+
Returns the standard deviation of the array elements, along given axis.
11751182
1183+
Refer to :obj:`dpnp.std` for full documentation.
11761184
"""
11771185

1178-
return dpnp.std(self, axis, dtype, out, ddof, keepdims)
1186+
return dpnp.std(self, axis, dtype, out, ddof, keepdims, where=where)
11791187

11801188
@property
11811189
def strides(self):
@@ -1207,10 +1215,7 @@ def sum(
12071215
"""
12081216
Returns the sum along a given axis.
12091217
1210-
.. seealso::
1211-
:obj:`dpnp.sum` for full documentation,
1212-
:meth:`dpnp.dparray.sum`
1213-
1218+
For full documentation refer to :obj:`dpnp.sum`.
12141219
"""
12151220

12161221
return dpnp.sum(
@@ -1307,23 +1312,22 @@ def transpose(self, *axes):
13071312
res._array_obj = dpt.permute_dims(self._array_obj, axes)
13081313
return res
13091314

1310-
def var(self, axis=None, dtype=None, out=None, ddof=0, keepdims=False):
1315+
def var(
1316+
self,
1317+
axis=None,
1318+
dtype=None,
1319+
out=None,
1320+
ddof=0,
1321+
keepdims=False,
1322+
*,
1323+
where=True,
1324+
):
13111325
"""
1312-
Returns the variance of the array elements along given axis.
1313-
1314-
Masked entries are ignored, and result elements which are not
1315-
finite will be masked.
1316-
1317-
Refer to `numpy.var` for full documentation.
1318-
1319-
See Also
1320-
--------
1321-
:obj:`numpy.ndarray.var` : corresponding function for ndarrays
1322-
:obj:`numpy.var` : Equivalent function
1326+
Returns the variance of the array elements, along given axis.
13231327
1328+
Refer to :obj:`dpnp.var` for full documentation.
13241329
"""
1325-
1326-
return dpnp.var(self, axis, dtype, out, ddof, keepdims)
1330+
return dpnp.var(self, axis, dtype, out, ddof, keepdims, where=where)
13271331

13281332

13291333
# 'view'

0 commit comments

Comments
 (0)