Skip to content

Commit

Permalink
vulkan: skip integer div/mod in get_offsets for batch_idx==0 (#10506)
Browse files Browse the repository at this point in the history
  • Loading branch information
jeffbolznv authored Nov 27, 2024
1 parent 4a57d36 commit 71a6498
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions ggml/src/ggml-vulkan/vulkan-shaders/mul_mat_vec_base.comp
Original file line number Diff line number Diff line change
Expand Up @@ -52,13 +52,16 @@ void get_offsets(out uint a_offset, out uint b_offset, out uint d_offset) {
#endif

#ifndef MUL_MAT_ID
const uint i13 = batch_idx / p.ne12;
const uint i12 = batch_idx % p.ne12;
uint batch_idx_a = 0;
if (batch_idx != 0) {
const uint i13 = batch_idx / p.ne12;
const uint i12 = batch_idx % p.ne12;

const uint i03 = i13 / p.broadcast3;
const uint i02 = i12 / p.broadcast2;
const uint i03 = i13 / p.broadcast3;
const uint i02 = i12 / p.broadcast2;

const uint batch_idx_a = i03 * p.ne02 + i02;
batch_idx_a = i03 * p.ne02 + i02;
}
#else
const uint expert_id = data_ids[expert_idx];
#endif
Expand Down

0 comments on commit 71a6498

Please sign in to comment.