-
Notifications
You must be signed in to change notification settings - Fork 14k
Vulkan: Add GGML_OP_GET_REL_POS
#17417
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
AgainstEntropy
wants to merge
7
commits into
ggml-org:master
Choose a base branch
from
AgainstEntropy:vulkan/rel-pos
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.
Open
Changes from 4 commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fb431da
vulkan: add get_rel_pos operation and corresponding shader
AgainstEntropy e94dc95
vulkan: fix floating point precision issue in get_rel_pos shader
AgainstEntropy e6eb7db
vulkan: refactored the ggml_vk_get_rel_pos function to use ggml_vk_op…
AgainstEntropy 41450b5
Merge remote-tracking branch 'origin/master' into vulkan/rel-pos
AgainstEntropy fd79273
vulkan: unlock incontiguous support for get_rel_pos
AgainstEntropy 0cd28b6
vulkan: enhance get_rel_pos handling for type checks and pipeline cre…
AgainstEntropy c25eb6f
Merge remote-tracking branch 'origin/master' into vulkan/rel-pos
AgainstEntropy 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| #version 450 | ||
|
|
||
| #include "types.glsl" | ||
| #include "generic_unary_head.glsl" | ||
|
|
||
| layout(local_size_x = 512, local_size_y = 1, local_size_z = 1) in; | ||
|
|
||
| void main() { | ||
| const uint idx = get_idx(); | ||
| if (idx >= p.ne) { | ||
| return; | ||
| } | ||
|
|
||
| const uint i13 = fastdiv(idx, p.ne1_012mp, p.ne1_012L); | ||
| const uint i13_offset = i13 * p.ne12*p.ne11*p.ne10; | ||
| const uint i12 = fastdiv(idx - i13_offset, p.ne1_01mp, p.ne1_01L); | ||
| const uint i12_offset = i12*p.ne11*p.ne10; | ||
| const uint i11 = fastdiv(idx - i13_offset - i12_offset, p.ne1_0mp, p.ne1_0L); | ||
| const uint i10 = idx - i13_offset - i12_offset - i11*p.ne10; | ||
|
|
||
| const float kh = float(p.ne11); | ||
| const float qh = float(p.ne12); | ||
| const float k_scale = max(qh / kh, 1.0f); | ||
| const float q_scale = max(kh / qh, 1.0f); | ||
|
|
||
| // Add a small epsilon to avoid floating point precision issues | ||
| const float epsilon = 0.0001f; | ||
| const int pos = int(float(i12) * q_scale - float(i11) * k_scale + (kh - 1.0f) * k_scale + epsilon); | ||
|
|
||
| const uint src_idx = pos*p.nb01 + i10*p.nb00; | ||
| const uint dst_idx = i13*p.nb13 + i12*p.nb12 + i11*p.nb11 + i10*p.nb10; | ||
|
|
||
| data_d[get_doffset() + dst_idx] = D_TYPE(data_a[get_aoffset() + src_idx]); | ||
| } | ||
|
|
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.
Uh oh!
There was an error while loading. Please reload this page.