From 43bfc95a5a0bae7bc6fb593e6b41ee423146d7c0 Mon Sep 17 00:00:00 2001 From: Adam Treat Date: Tue, 13 Feb 2024 14:20:06 -0500 Subject: [PATCH] Early return after the assertions. Signed-off-by: Adam Treat --- ggml-backend.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/ggml-backend.c b/ggml-backend.c index cf6f485bf..87eea8440 100644 --- a/ggml-backend.c +++ b/ggml-backend.c @@ -213,30 +213,30 @@ void ggml_backend_tensor_get_async(ggml_backend_t backend, const struct ggml_ten } GGML_CALL void ggml_backend_tensor_set(struct ggml_tensor * tensor, const void * data, size_t offset, size_t size) { - if (!size) { - return; - } - ggml_backend_buffer_t buf = tensor->view_src ? tensor->view_src->buffer : tensor->buffer; GGML_ASSERT(tensor->data != NULL && "tensor not allocated"); GGML_ASSERT(buf != NULL && "tensor buffer not set"); GGML_ASSERT(offset + size <= ggml_nbytes(tensor) && "tensor write out of bounds"); - tensor->buffer->iface.set_tensor(buf, tensor, data, offset, size); -} - -GGML_CALL void ggml_backend_tensor_get(const struct ggml_tensor * tensor, void * data, size_t offset, size_t size) { if (!size) { return; } + tensor->buffer->iface.set_tensor(buf, tensor, data, offset, size); +} + +GGML_CALL void ggml_backend_tensor_get(const struct ggml_tensor * tensor, void * data, size_t offset, size_t size) { ggml_backend_buffer_t buf = tensor->view_src ? tensor->view_src->buffer : tensor->buffer; GGML_ASSERT(tensor->data != NULL && "tensor not allocated"); 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); }