Skip to content

Commit d20e97a

Browse files
committed
Cleanup im2col shader
1 parent d151973 commit d20e97a

File tree

1 file changed

+8
-7
lines changed

1 file changed

+8
-7
lines changed

ggml/src/ggml-vulkan/vulkan-shaders/im2col.comp

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,19 +68,20 @@ void main() {
6868
continue;
6969
}
7070

71-
const uint iiw = int(current_ix) * p.s0 + int(current_kx) * p.d0 - p.p0;
72-
const uint iih = oh_s1 + int(current_ky) * p.d1 - p.p1;
71+
const uint iiw = current_ix * p.s0 + current_kx * p.d0 - p.p0;
72+
const uint iih = oh_s1 + current_ky * p.d1 - p.p1;
7373

7474
offset_dst[idx] = dst_base + current_ix * p.CHW + current_ky * p.KW + current_kx;
7575

76-
const bool valid = (iih >= 0 && iih < int(p.IH)) && (iiw >= 0 && iiw < int(p.IW));
77-
if (valid) {
78-
values[idx] = data_a[src_base + uint(iih) * p.IW + uint(iiw)];
76+
if ((iih < p.IH) && (iiw < p.IW)) {
77+
values[idx] = data_a[src_base + iih * p.IW + iiw];
7978
}
8079

81-
if (++current_ix == p.OW) {
80+
current_ix++;
81+
if (current_ix == p.OW) {
8282
current_ix = 0;
83-
if (++current_ky == max_ky) {
83+
current_ky++;
84+
if (current_ky == max_ky) {
8485
current_ky = 0;
8586
current_kx++;
8687
}

0 commit comments

Comments
 (0)