-
Notifications
You must be signed in to change notification settings - Fork 22
Kernel abs #104
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
Kernel abs #104
Conversation
void* result1, | ||
size_t size) | ||
{ | ||
if (!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.
I think, It is better to add size check on cython level.
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.
@samir-nasibli it should be here. Let's imagine if somebody will call this kernels from C++ application.
Codecov Report
@@ Coverage Diff @@
## master #104 +/- ##
=======================================
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.
|
|
||
template <typename _DataType> | ||
void custom_elemwise_absolute_c(void* array1_in, | ||
const std::vector<long>& input_shape, |
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.
@Rubtsowa Please avoid of using complex types like std::vector in interface, if you need to provide set of values then use pointers. At this moment it is hard to use such params in calls from another projects like Numba, for example. We already had discussions about it.
But in this function this param is useless at all. You don't need it and you didn't use this param, look at another comments.
const size_t input_shape_size = input_shape.size(); | ||
size_t* input_offset_shape = reinterpret_cast<size_t*>(dpnp_memory_alloc_c(input_shape_size * sizeof(long))); | ||
size_t* result_offset_shape = reinterpret_cast<size_t*>(dpnp_memory_alloc_c(input_shape_size * sizeof(long))); |
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.
@Rubtsowa This code is useless. BTW it is only place where input_shape is used.
DPNP_FN_NONE, /**< Very first element of the enumeration */ | ||
DPNP_FN_ABSOLUTE, /**< Used in numpy.absolute() implementation */ |
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.
@Rubtsowa These rows show that codestyle was not applied. Please use codestyle tools.
* | ||
* @param [in] array1_in Input array. | ||
* | ||
* @param [in] input_shape Input shape. |
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.
@Rubtsowa Unnecessary param
*/ | ||
template <typename _DataType> | ||
INP_DLLEXPORT void custom_elemwise_absolute_c(void* array1_in, | ||
const std::vector<long>& input_shape, |
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.
@Rubtsowa Unnecessary param
template void custom_elemwise_absolute_c<double>(void* array1_in, | ||
const std::vector<long>& input_shape, | ||
void* result1, | ||
size_t size); | ||
template void custom_elemwise_absolute_c<float>(void* array1_in, | ||
const std::vector<long>& input_shape, | ||
void* result1, | ||
size_t size); | ||
template void custom_elemwise_absolute_c<long>(void* array1_in, | ||
const std::vector<long>& input_shape, | ||
void* result1, | ||
size_t size); | ||
template void custom_elemwise_absolute_c<int>(void* array1_in, | ||
const std::vector<long>& input_shape, | ||
void* result1, | ||
size_t 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.
@Rubtsowa input_shape is unnecessary param
@@ -63,54 +63,29 @@ __all__ += [ | |||
] | |||
|
|||
|
|||
ctypedef void(*fptr_custom_elemwise_absolute_1in_1out_t)(void *, dparray_shape_type &, |
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.
@Rubtsowa Unnecessary param
|
||
cdef fptr_custom_elemwise_absolute_1in_1out_t func = <fptr_custom_elemwise_absolute_1in_1out_t > kernel_data.ptr | ||
# call FPTR function | ||
func(input.get_data(), input_shape, result.get_data(), input.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.
@Rubtsowa Unnecessary param
dpnp_result_array = dpnp_array.reshape(output_shape) | ||
return dpnp_result_array | ||
cdef dparray_shape_type input_shape = input.shape | ||
cdef size_t input_shape_size = input.ndim |
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.
@Rubtsowa input_shape_size is not used
dpnp_array = dpnp.array(result_array, dtype=input.dtype) | ||
dpnp_result_array = dpnp_array.reshape(output_shape) | ||
return dpnp_result_array | ||
cdef dparray_shape_type input_shape = input.shape |
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.
@Rubtsowa Unnecessary param
No description provided.