Skip to content

Commit 4b23d88

Browse files
CISCstruct
authored andcommitted
opencl: fix im2col when KW!=KH (ggml-org#14803)
1 parent 6c9ee3b commit 4b23d88

File tree

3 files changed

+8
-8
lines changed

3 files changed

+8
-8
lines changed

ggml/src/ggml-opencl/kernels/im2col_f16.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ kernel void kernel_im2col_f16(
3131
src1 = (global float*)((global char*)src1 + offset1);
3232
dst = (global half*)((global char*)dst + offsetd);
3333

34-
long ksize = OW * (KH > 1 ? KW : 1);
34+
long ksize = OW * KH;
3535
long kx = i / ksize;
3636
long kd = kx * ksize;
3737
long ky = (i - kd) / OW;

ggml/src/ggml-opencl/kernels/im2col_f32.cl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ kernel void kernel_im2col_f32(
3131
src1 = (global float*)((global char*)src1 + offset1);
3232
dst = (global float*)((global char*)dst + offsetd);
3333

34-
long ksize = OW * (KH > 1 ? KW : 1);
34+
long ksize = OW * KH;
3535
long kx = i / ksize;
3636
long kd = kx * ksize;
3737
long ky = (i - kd) / OW;

ggml/src/gguf.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -486,6 +486,8 @@ struct gguf_context * gguf_init_from_file_impl(FILE * file, struct gguf_init_par
486486
}
487487

488488
// read the tensor info
489+
std::unordered_map<std::string, int64_t> tensor_names;
490+
489491
for (int64_t i = 0; ok && i < n_tensors; ++i) {
490492
struct gguf_tensor_info info;
491493

@@ -509,12 +511,10 @@ struct gguf_context * gguf_init_from_file_impl(FILE * file, struct gguf_init_par
509511
ggml_set_name(&info.t, name.c_str());
510512

511513
// make sure there are no duplicate tensor names
512-
for (int64_t j = 0; ok && j < i; ++j) {
513-
if (strcmp(info.t.name, ctx->info[j].t.name) == 0) {
514-
GGML_LOG_ERROR("%s: duplicate tensor name '%s' for tensors %" PRIi64 " and %" PRIi64 "\n", __func__, info.t.name, j, i);
515-
ok = false;
516-
break;
517-
}
514+
auto [it, result] = tensor_names.emplace(info.t.name, i);
515+
if (!result) {
516+
GGML_LOG_ERROR("%s: duplicate tensor name '%s' for tensors %" PRIi64 " and %" PRIi64 "\n", __func__, info.t.name, i, it->second);
517+
ok = false;
518518
}
519519
}
520520
if (!ok) {

0 commit comments

Comments
 (0)