]> git.djapps.eu Git - pkg/ggml/sources/whisper.cpp/commitdiff
Early return for zero size calls to get_tensor. (llama/5482)
authorAT <redacted>
Tue, 13 Feb 2024 21:44:25 +0000 (15:44 -0600)
committerGeorgi Gerganov <redacted>
Mon, 19 Feb 2024 13:53:22 +0000 (15:53 +0200)
* Early return for zero size calls to get_tensor.

Signed-off-by: Adam Treat <redacted>
* Update ggml-kompute.cpp

Co-authored-by: Georgi Gerganov <redacted>
* Update ggml-kompute.cpp

Co-authored-by: Georgi Gerganov <redacted>
* Add an early return to the get/set tensor when the size is null.

Signed-off-by: Adam Treat <redacted>
* Early return after the assertions.

Signed-off-by: Adam Treat <redacted>
* Since we do the early return in the generic backend now no reason to do so here as well.

Signed-off-by: Adam Treat <redacted>
---------

Signed-off-by: Adam Treat <redacted>
Co-authored-by: Georgi Gerganov <redacted>
ggml-backend.c

index 9ee81b766f1a81a688a2a056298e129472d9e94d..87eea84402e926b8b7ae2a2230b021a0a208a7b2 100644 (file)
@@ -219,6 +219,10 @@ GGML_CALL void ggml_backend_tensor_set(struct ggml_tensor * tensor, const void *
     GGML_ASSERT(buf != NULL && "tensor buffer not set");
     GGML_ASSERT(offset + size <= ggml_nbytes(tensor) && "tensor write out of bounds");
 
+    if (!size) {
+        return;
+    }
+
     tensor->buffer->iface.set_tensor(buf, tensor, data, offset, size);
 }
 
@@ -229,6 +233,10 @@ GGML_CALL void ggml_backend_tensor_get(const struct ggml_tensor * tensor, void *
     GGML_ASSERT(tensor->buffer != NULL && "tensor buffer not set");
     GGML_ASSERT(offset + size <= ggml_nbytes(tensor) && "tensor read out of bounds");
 
+    if (!size) {
+        return;
+    }
+
     tensor->buffer->iface.get_tensor(buf, tensor, data, offset, size);
 }