Skip to content

Commit e67feaf

Browse files
committed
ggml-zdnn: fix ztensor deallocation abort
stabilise ggml <-> zdnn api Signed-off-by: Aaron Teo <[email protected]>
1 parent 803dde3 commit e67feaf

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ggml/src/ggml-zdnn/ggml-zdnn-rewrite.cpp

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,9 @@ static void ggml_backend_zdnn_buffer_free_buffer(ggml_backend_buffer_t buffer) {
379379
ggml_backend_zdnn_buffer_context * ctx = (ggml_backend_zdnn_buffer_context *)buffer->context;
380380

381381
for (int i = 0; i < ctx->n_buffers; i++) {
382-
ZDNN_CHECK(zdnn_free_ztensor_buffer(&ctx->buffers[i]->ztensor));
382+
if (ctx->buffers[i]->ztensor.buffer != NULL && ctx->buffers[i]->ztensor.is_transformed) {
383+
ZDNN_CHECK(zdnn_free_ztensor_buffer(&ctx->buffers[i]->ztensor));
384+
}
383385
}
384386

385387
delete ctx;

0 commit comments

Comments
 (0)