-
Notifications
You must be signed in to change notification settings - Fork 23
Kernels for max min mean median #102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
Codecov Report
@@ Coverage Diff @@
## master #102 +/- ##
=======================================
Coverage 51.45% 51.45%
=======================================
Files 19 19
Lines 1201 1201
Branches 312 312
=======================================
Hits 618 618
Misses 333 333
Partials 250 250 Continue to review full report at Codecov.
|
dpnp/backend_statistics.pyx
Outdated
|
||
|
||
# C function pointer to the C library template functions | ||
ctypedef void(*custom_statistic_1in_1out_func_ptr_t)(void * , void * , size_t) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could use existing fptr_1in_1out_t
from backend
instead of custom_statistic_1in_1out_func_ptr_t
.
dpnp/backend_statistics.pyx
Outdated
@@ -87,7 +91,26 @@ cpdef dparray dpnp_cov(dparray array1): | |||
return result | |||
|
|||
|
|||
cpdef dparray _dpnp_max(dparray input): | |||
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(input.dtype) | |||
cdef DPNPFuncType output_type = dpnp_dtype_to_DPNPFuncType(input.dtype) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
output_type
is equal to param1_type
, so you could just use param1_type
instead of output_type
. I'm not sure about cython but maybe it will work:
cdef DPNPFuncType param1_type = output_type = dpnp_dtype_to_DPNPFuncType(input.dtype)
or you could use DPNP_FT_NONE
as the third argument of get_dpnp_function_ptr
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I thought that the third parameter of get_dpnp_function_ptr
isn't output type, but it's type of the second input parameter. Please correct me if I'm wrong.
dpnp/backend_statistics.pyx
Outdated
@@ -166,7 +189,26 @@ cpdef dparray dpnp_max(dparray input, axis): | |||
return dpnp_result_array | |||
|
|||
|
|||
cpdef dparray _dpnp_mean(dparray input): | |||
cdef DPNPFuncType param1_type = dpnp_dtype_to_DPNPFuncType(input.dtype) | |||
cdef DPNPFuncType output_type = dpnp_dtype_to_DPNPFuncType(numpy.float64 if input.dtype != numpy.float32 else numpy.float32) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Isn't it resolved by fmap[DPNPFuncName::DPNP_FN_MEAN][eft_FLT][eft_FLT] = {eft_FLT, (void*)custom_mean_c<float, float>};
?
_DataType* sum = reinterpret_cast<_DataType*>(dpnp_memory_alloc_c(1 * sizeof(_DataType))); | ||
|
||
custom_sum_c<_DataType>(array1_in, sum, size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_DataType* sum = reinterpret_cast<_DataType*>(dpnp_memory_alloc_c(1 * sizeof(_DataType))); | |
custom_sum_c<_DataType>(array1_in, sum, size); | |
_DataType sum; | |
custom_sum_c<_DataType>(array1_in, &sum, size); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
oh... no. we need USM memory for kernel. sorry - my proposal is wrong.
perhaps it is better to use *result
memory for this
No description provided.