Skip to content

Commit 973948b

Browse files
committed
ggml-hexagon: apply similar logic as in ggml-vulkan
1 parent c41f7c1 commit 973948b

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ggml/src/ggml-hexagon/ggml-hexagon.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6239,10 +6239,13 @@ static ggml_backend_buffer_t ggml_backend_hexagon_buffer_type_alloc_buffer(
62396239
if ((HWACCEL_CDSP == g_hexagon_appcfg.hwaccel_approach) && (1 == g_hexagon_appcfg.enable_rpc_ion_mempool)) {
62406240
GGMLHEXAGON_LOG_DEBUG("device %d(%s)", ctx->device, ggml_backend_hexagon_get_devname(ctx->device));
62416241
GGML_ASSERT(nullptr != ctx->rpc_mempool);
6242-
GGMLHEXAGON_LOG_DEBUG("size %ld(%d MiB), rpc_mempool_usage %ld(%d MiB), rpc_mempool_len %ld(%d MiB)",
6242+
GGMLHEXAGON_LOG_VERBOSE("size %ld(%d MiB), rpc_mempool_usage %ld(%d MiB), rpc_mempool_len %ld(%d MiB)",
62436243
size, size / SIZE_IN_MB, ctx->rpc_mempool_usage, ctx->rpc_mempool_usage / SIZE_IN_MB,
62446244
ctx->rpc_mempool_len, ctx->rpc_mempool_len / SIZE_IN_MB);
6245-
GGML_ASSERT(size + ctx->rpc_mempool_usage <= ctx->rpc_mempool_len);
6245+
if (size + ctx->rpc_mempool_usage >= ctx->rpc_mempool_len) {
6246+
GGMLHEXAGON_LOG_WARN("device memory allocation of size %ld failed", size);
6247+
return nullptr;
6248+
}
62466249
buffer_ctx->buffer = (static_cast<char*>(ctx->rpc_mempool)) + ctx->rpc_mempool_usage;
62476250
GGMLHEXAGON_LOG_DEBUG("buffer_ctx->buffer %p", buffer_ctx->buffer);
62486251
GGML_ASSERT(nullptr != buffer_ctx->buffer);

0 commit comments

Comments
 (0)