Repository navigation
MULTIPLY enable broadcasting #655
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
Changes from 1 commit
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
6887fb3
MULTIPLY enable broadcasting
densmirn b66a4e8
Add gtests for broadcast iterator
densmirn 052a307
Expand memory free before broadcasting
densmirn 6f6f9ed
Disable broadcasting in element-wise operations
densmirn bc0c1f7
Change docs for 2 DPNPC_id methods
densmirn 257700d
Merge branch 'master' of https://github.com/IntelPython/dpnp into fea…
densmirn 7f2e8e2
Change memory free call before broadcasting
densmirn 0731675
Enable gtests on broadcasting on GPU
densmirn da181e2
Enable broadcasting in element-wise operations
densmirn 3b30fb6
Merge branch 'master' of https://github.com/IntelPython/dpnp into fea…
densmirn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next
Next commit
MULTIPLY enable broadcasting
- Loading branch information
commit 6887fb39411f1b431d465b4562a575b40c80ccba
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,6 +28,7 @@ | |
|
|
||
| #include <dpnp_iface.hpp> | ||
| #include "dpnp_fptr.hpp" | ||
| #include "dpnp_iterator.hpp" | ||
| #include "dpnp_utils.hpp" | ||
| #include "queue_sycl.hpp" | ||
|
|
||
|
|
@@ -353,29 +354,38 @@ static void func_map_init_elemwise_1arg_1type(func_map_t& fmap) | |
| const size_t* where) \ | ||
| { \ | ||
| /* avoid warning unused variable*/ \ | ||
| (void)input1_shape; \ | ||
| (void)input1_shape_ndim; \ | ||
| (void)input2_shape; \ | ||
| (void)input2_shape_ndim; \ | ||
| (void)where; \ | ||
| \ | ||
| if (!input1_size || !input2_size) \ | ||
| { \ | ||
| return; \ | ||
| } \ | ||
| \ | ||
| const size_t result_size = (input2_size > input1_size) ? input2_size : input1_size; \ | ||
| \ | ||
| const _DataType_input1* input1_data = reinterpret_cast<const _DataType_input1*>(input1_in); \ | ||
| const _DataType_input2* input2_data = reinterpret_cast<const _DataType_input2*>(input2_in); \ | ||
| _DataType_input1* input1_data = reinterpret_cast<_DataType_input1*>(const_cast<void*>(input1_in)); \ | ||
| _DataType_input2* input2_data = reinterpret_cast<_DataType_input2*>(const_cast<void*>(input2_in)); \ | ||
| _DataType_output* result = reinterpret_cast<_DataType_output*>(result_out); \ | ||
| \ | ||
| std::vector<size_t> result_shape = get_common_shape(input1_shape, input1_shape_ndim, \ | ||
| input2_shape, input2_shape_ndim); \ | ||
| \ | ||
| DPNPC_id<_DataType_input1> input1(input1_data, input1_shape, input1_shape_ndim); \ | ||
| input1.broadcast(result_shape); \ | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "broadcast_to_shape" func name? |
||
| \ | ||
| DPNPC_id<_DataType_input2> input2(input2_data, input2_shape, input2_shape_ndim); \ | ||
| input2.broadcast(result_shape); \ | ||
| \ | ||
| const size_t result_size = input1.get_output_size(); \ | ||
| \ | ||
| cl::sycl::range<1> gws(result_size); \ | ||
| const DPNPC_id<_DataType_input1>* input1_it = &input1; \ | ||
| const DPNPC_id<_DataType_input2>* input2_it = &input2; \ | ||
| auto kernel_parallel_for_func = [=](cl::sycl::id<1> global_id) { \ | ||
| size_t i = global_id[0]; /*for (size_t i = 0; i < result_size; ++i)*/ \ | ||
| const _DataType_output input1_elem = (input1_size == 1) ? input1_data[0] : input1_data[i]; \ | ||
| const _DataType_output input2_elem = (input2_size == 1) ? input2_data[0] : input2_data[i]; \ | ||
| result[i] = __operation1__; \ | ||
| const size_t i = global_id[0]; /*for (size_t i = 0; i < result_size; ++i)*/ \ | ||
| { \ | ||
| const _DataType_output input1_elem = (*input1_it)[i]; \ | ||
| const _DataType_output input2_elem = (*input2_it)[i]; \ | ||
| result[i] = __operation1__; \ | ||
| } \ | ||
| }; \ | ||
| auto kernel_func = [&](cl::sycl::handler& cgh) { \ | ||
| cgh.parallel_for<class __name__##_kernel<_DataType_output, _DataType_input1, \ | ||
|
|
@@ -390,9 +400,7 @@ static void func_map_init_elemwise_1arg_1type(func_map_t& fmap) | |
| std::is_same<_DataType_input1, float>::value) && \ | ||
| std::is_same<_DataType_input2, _DataType_input1>::value) \ | ||
| { \ | ||
| _DataType_input1* input1 = const_cast<_DataType_input1*>(input1_data); \ | ||
| _DataType_input2* input2 = const_cast<_DataType_input2*>(input2_data); \ | ||
| event = __operation2__(DPNP_QUEUE, result_size, input1, input2, result); \ | ||
| event = __operation2__(DPNP_QUEUE, result_size, input1_data, input2_data, result); \ | ||
| } \ | ||
| else \ | ||
| { \ | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
maybe "get_result_shape" is better for this function name? not sure...