Skip to content

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

Merged
merged 4 commits into from
Oct 1, 2020
Merged

Conversation

Alexander-Makaryev
Copy link
Contributor

No description provided.

@codecov
Copy link

codecov bot commented Oct 1, 2020

Codecov Report

Merging #102 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           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.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5f71e74...a9bf072. Read the comment docs.



# C function pointer to the C library template functions
ctypedef void(*custom_statistic_1in_1out_func_ptr_t)(void * , void * , size_t)
Copy link
Contributor

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.

@@ -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)
Copy link
Contributor

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.

Copy link
Contributor

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.

@@ -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)
Copy link
Contributor

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>};?

Comment on lines +189 to +191
_DataType* sum = reinterpret_cast<_DataType*>(dpnp_memory_alloc_c(1 * sizeof(_DataType)));

custom_sum_c<_DataType>(array1_in, sum, size);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
_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);

Copy link
Contributor

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

@shssf shssf merged commit ff875ab into master Oct 1, 2020
@shssf shssf deleted the kernels-max-min-mean-median branch October 1, 2020 18:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants