]> git.djapps.eu Git - pkg/ggml/sources/llama.cpp/commitdiff
sync : ggml (fix im2col) (#4591)
authorGeorgi Gerganov <redacted>
Fri, 22 Dec 2023 15:53:43 +0000 (17:53 +0200)
committerGitHub <redacted>
Fri, 22 Dec 2023 15:53:43 +0000 (17:53 +0200)
* cuda : fix im2col_f32_f16 (ggml/#658)

ggml-ci

* ggml-alloc : fix ggml_tallocr_is_own

---------

Co-authored-by: leejet <redacted>
ggml-alloc.c
ggml-cuda.cu

index a97436b17ed70d49e6e3741e953457b275512d20..a27dd54b0eb062f9cc5638324ef96ae39725b1b5 100644 (file)
@@ -72,7 +72,7 @@ static void remove_allocated_tensor(ggml_tallocr_t alloc, struct ggml_tensor * t
 
 // check if a tensor is allocated by this buffer
 static bool ggml_tallocr_is_own(ggml_tallocr_t alloc, const struct ggml_tensor * tensor) {
-    return tensor->buffer == alloc->buffer;
+    return tensor->buffer == alloc->buffer && (!tensor->view_src || tensor->view_src->buffer == alloc->buffer);
 }
 
 static bool ggml_is_view(struct ggml_tensor * t) {
index b124774a9336020cbc25d4add64a3403321df1aa..7c2a834e34382f44ca788ff006d3877f8bab1fa3 100644 (file)
@@ -5273,17 +5273,17 @@ static  __global__ void im2col_f32_f16(
     const int ky = (i - kd) / OW;
     const int ix = i % OW;
 
-    const int iiw = ix * s0 + kx * d0 - p0;
-    const int iih = blockIdx.y * s1 + ky * d1 - p1;
+    const int64_t iiw = ix * s0 + kx * d0 - p0;
+    const int64_t iih = blockIdx.y * s1 + ky * d1 - p1;
 
-    const int offset_dst =
+    const int64_t offset_dst =
         (blockIdx.y * OW + ix) * CHW +
         (blockIdx.z * (KW * KH) + ky * KW + kx);
 
     if (iih < 0 || iih >= IH || iiw < 0 || iiw >= IW) {
         dst[offset_dst] = __float2half(0.0f);
     } else {
-        const int offset_src = blockIdx.z * offset_delta;
+        const int64_t offset_src = blockIdx.z * offset_delta;
         dst[offset_dst] = __float2half(x[offset_src + iih * IW + iiw]);
     }
 }