-
Notifications
You must be signed in to change notification settings - Fork 13.9k
Add circular tiling support to pad, for Vulkan, CUDA, and CPU (used for making seamless textures) #16985
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
Open
Phylliida
wants to merge
18
commits into
ggml-org:master
Choose a base branch
from
Phylliida:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+185
−42
Open
Add circular tiling support to pad, for Vulkan, CUDA, and CPU (used for making seamless textures) #16985
Changes from all commits
Commits
Show all changes
18 commits
Select commit
Hold shift + click to select a range
f6ac084
Feat: Added vulkan circular tiling support
Phylliida d7f5958
Feat: Added cpu circular
Phylliida 1b62b49
Feat: Added cuda kernels
Phylliida 60bed3b
Added tests
Phylliida 5700a4e
Added tests
Phylliida a894631
Merge branch 'master' into master
Phylliida 9861a3d
Removed non-pad operations
Phylliida 38f8724
Removed unneded changes
Phylliida d4a664b
removed backend non pad tests
Phylliida a785537
Merge branch 'ggml-org:master' into master
Phylliida d9dc234
Merge branch 'ggml-org:master' into master
Phylliida 552e5b2
Update test-backend-ops.cpp
Phylliida 1c69e4e
Fixed comment on pad test
Phylliida 3cd8167
Merge branch 'ggml-org:master' into master
Phylliida 429854b
removed trailing whitespace
cf720e8
Removed unneded test in test-backend-ops
b65967a
Merge branch 'ggml-org:master' into master
Phylliida a0bbbc2
Removed removed test from calls
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
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 |
|---|---|---|
|
|
@@ -8,6 +8,7 @@ layout (push_constant) uniform parameter | |
| uint ne00; uint ne01; uint ne02; uint ne03; uint nb00; uint nb01; uint nb02; uint nb03; | ||
| uint ne10; uint ne11; uint ne12; uint ne13; uint nb10; uint nb11; uint nb12; uint nb13; | ||
| uint misalign_offsets; | ||
| uint circular; | ||
|
|
||
| uint lp0; uint rp0; | ||
| uint lp1; uint rp1; | ||
|
|
@@ -18,6 +19,10 @@ layout (push_constant) uniform parameter | |
| uint get_aoffset() { return p.misalign_offsets >> 16; } | ||
| uint get_doffset() { return p.misalign_offsets & 0xFFFF; } | ||
|
|
||
| uint wrap_coord(int coord, uint size) { | ||
| return (uint(coord + int(size))) % size; // add size to avoid issues with negative | ||
| } | ||
|
|
||
| layout (binding = 0) readonly buffer A {A_TYPE data_a[];}; | ||
| layout (binding = 1) writeonly buffer D {D_TYPE data_d[];}; | ||
|
|
||
|
|
@@ -40,10 +45,21 @@ void main() { | |
| const uint src0_idx = (i3 - p.lp3)*p.nb03 + (i2 - p.lp2)*p.nb02 + (i1 - p.lp1)*p.nb01 + (i0 - p.lp0)*p.nb00; | ||
| const uint dst_idx = i3*p.nb13 + i2*p.nb12 + i1*p.nb11 + i0*p.nb10; | ||
|
|
||
| const bool is_src0 = i0 >= p.lp0 && i0 < p.ne10 - p.rp0 && | ||
| i1 >= p.lp1 && i1 < p.ne11 - p.rp1 && | ||
| i2 >= p.lp2 && i2 < p.ne12 - p.rp2 && | ||
| i3 >= p.lp3 && i3 < p.ne13 - p.rp3; | ||
| if (p.circular != 0u) { | ||
| const uint ci0 = wrap_coord(int(i0) - int(p.lp0), p.ne00); | ||
| const uint ci1 = wrap_coord(int(i1) - int(p.lp1), p.ne01); | ||
| const uint ci2 = wrap_coord(int(i2) - int(p.lp2), p.ne02); | ||
| const uint ci3 = wrap_coord(int(i3) - int(p.lp3), p.ne03); | ||
| const uint circular_src_idx = ci3*p.nb03 + ci2*p.nb02 + ci1*p.nb01 + ci0*p.nb00; | ||
| data_d[get_doffset() + dst_idx] = D_TYPE(data_a[get_aoffset() + circular_src_idx]); | ||
| } | ||
| else { | ||
| const bool is_src0 = i0 >= p.lp0 && i0 < p.ne10 - p.rp0 && | ||
| i1 >= p.lp1 && i1 < p.ne11 - p.rp1 && | ||
| i2 >= p.lp2 && i2 < p.ne12 - p.rp2 && | ||
| i3 >= p.lp3 && i3 < p.ne13 - p.rp3; | ||
|
Comment on lines
+57
to
+60
Collaborator
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. Please fix the alignment |
||
| data_d[get_doffset() + dst_idx] = D_TYPE(is_src0 ? data_a[get_aoffset() + src0_idx] : 0.0f); | ||
| } | ||
|
|
||
|
|
||
| data_d[get_doffset() + dst_idx] = D_TYPE(is_src0 ? data_a[get_aoffset() + src0_idx] : 0.0f); | ||
| } | ||
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
Oops, something went wrong.
Oops, something went wrong.
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.