-
Notifications
You must be signed in to change notification settings - Fork 13.9k
sycl: add PAD_REFLECT_D1 operator support #16145
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
+90
−3
Merged
Changes from 2 commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
8b20ac6
sycl: add PAD_REFLECT_D1 operator support
ye-NX d469c5b
docs(ops): regenerate docs/ops.md
ye-NX 946def0
remove trailing whitespaces
ye-NX 974ff97
style: fix editorconfig issues — trim trailing spaces and normalize EOLs
ye-NX 352d056
fix: move PAD_REFLECT_1D case outside of fall-through block
ye-NX 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
Some comments aren't visible on the classic Files Changed page.
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
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
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 |
|---|---|---|
| @@ -0,0 +1,77 @@ | ||
| #include "pad_reflect_1d.hpp" | ||
|
|
||
| void pad_reflect_1d_f32(const float* src,float* dst, | ||
| const int64_t ne0, const int64_t ne02, const int p0, const int p1, | ||
| const int64_t nb0, const int64_t nb1, const int64_t nb2, const int64_t nb3, | ||
| const int64_t nb00, const int64_t nb01, const int64_t nb02, const int64_t nb03, | ||
| const sycl::nd_item<3> &item_ct1){ | ||
|
|
||
| const int i0 = item_ct1.get_group(0) * SYCL_CONCAT_BLOCK_SIZE + item_ct1.get_local_id(0); | ||
| const int i1 = item_ct1.get_group(1); | ||
| const int g2 = item_ct1.get_group(2); | ||
| const int i2 = g2 % ne02; | ||
| const int i3 = g2 / ne02; | ||
|
|
||
| if (i0 >= p0 + ne0 + p1) return; | ||
|
|
||
| int t = i0 - p0; | ||
| int period = 2 * ne0 -2; | ||
| int m = t % period; | ||
| m += (m < 0) * period; | ||
| int center = ne0 -1; | ||
| int srci0 = center - abs(center - m); | ||
|
|
||
| int offest_src = i3*nb3 + i2*nb2 + i1*nb1 + srci0*nb0; | ||
| int offest_dst = i3*nb03 + i2*nb02 + i1*nb01 + i0*nb00; | ||
| dst[offest_dst] = src[offest_src]; | ||
|
|
||
| } | ||
|
|
||
| void ggml_sycl_op_pad_reflect_1d(ggml_backend_sycl_context& ctx, ggml_tensor* dst){ | ||
|
|
||
| const ggml_tensor * src0 = dst->src[0]; | ||
| queue_ptr stream = ctx.stream(); | ||
|
|
||
| GGML_ASSERT(src0->type == GGML_TYPE_F32); | ||
| GGML_ASSERT( dst->type == GGML_TYPE_F32); | ||
|
|
||
| const int32_t * opts = (const int32_t *) dst->op_params; | ||
| const int p0 = opts[0]; | ||
| const int p1 = opts[1]; | ||
|
|
||
| const int64_t ne0 = src0->ne[0]; | ||
|
|
||
| const int64_t ne00 = dst->ne[0]; | ||
| const int64_t ne01 = dst->ne[1]; | ||
| const int64_t ne02 = dst->ne[2]; | ||
| const int64_t ne03 = dst->ne[3]; | ||
|
|
||
| const int64_t nb00 = dst->nb[0]; | ||
| const int64_t nb01 = dst->nb[1]; | ||
| const int64_t nb02 = dst->nb[2]; | ||
| const int64_t nb03 = dst->nb[3]; | ||
| const int64_t nb0 = src0->nb[0]; | ||
| const int64_t nb1 = src0->nb[1]; | ||
| const int64_t nb2 = src0->nb[2]; | ||
| const int64_t nb3 = src0->nb[3]; | ||
|
|
||
| int num_blocks = (ne00 + SYCL_CONCAT_BLOCK_SIZE - 1) / SYCL_CONCAT_BLOCK_SIZE; | ||
|
|
||
| sycl::range<3> global(num_blocks * SYCL_CONCAT_BLOCK_SIZE, ne01, ne02*ne03); | ||
ye-NX marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| sycl::range<3> local(SYCL_CONCAT_BLOCK_SIZE, 1, 1); | ||
|
|
||
| stream->parallel_for( | ||
| sycl::nd_range<3>(global, | ||
| local), | ||
| [=](sycl::nd_item<3> item_ct1) { pad_reflect_1d_f32( | ||
| (const float *) src0->data, (float *) dst->data, | ||
| ne0, ne02, p0, p1, | ||
| nb0, nb1, nb2, nb3, | ||
| nb00, nb01, nb02, nb03 | ||
| , item_ct1); | ||
| }); | ||
| } | ||
|
|
||
|
|
||
|
|
||
|
|
||
ye-NX marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||
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 |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| #ifndef GGML_SYCL_PAD_REFLECT_1D_HPP | ||
| #define GGML_SYCL_PAD_REFLECT_1D_HPP | ||
|
|
||
| #include "common.hpp" | ||
|
|
||
| void ggml_sycl_op_pad_reflect_1d(ggml_backend_sycl_context& ctx, ggml_tensor* dst); | ||
|
|
||
| #endif // GGML_SYCL_PAD_REFLECT_1D_HPP |
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.
Uh oh!
There was an error while loading. Please reload this page.