From 63d7ff254d961ab855658728eb551f9b29671df4 Mon Sep 17 00:00:00 2001 From: Hyeongseok Oh Date: Thu, 10 Oct 2024 18:22:17 +0900 Subject: [PATCH] [onert/cpu] Update ggml usage (#14194) This commit updates usage of ggml in Gather and FullyConnected - Use vector for plan buffer - Use general thread number getter ONE-DCO-1.0-Signed-off-by: Hyeongseok Oh --- runtime/onert/backend/cpu/ops/FullyConnectedLayer.cc | 8 +++----- runtime/onert/backend/cpu/ops/GatherLayer.cc | 6 ++---- 2 files changed, 5 insertions(+), 9 deletions(-) diff --git a/runtime/onert/backend/cpu/ops/FullyConnectedLayer.cc b/runtime/onert/backend/cpu/ops/FullyConnectedLayer.cc index d910881ace2..c2decaf6ca1 100644 --- a/runtime/onert/backend/cpu/ops/FullyConnectedLayer.cc +++ b/runtime/onert/backend/cpu/ops/FullyConnectedLayer.cc @@ -204,14 +204,12 @@ void FullyConnectedLayer::fullyConnectedGGMLWeight() } // get cplan - auto cplan = ggml_graph_plan(&graph, _external_context->ruy_context()->max_num_threads()); - cplan.work_data = (uint8_t *)(malloc(cplan.work_size)); + auto cplan = ggml_graph_plan(&graph, _external_context->maxNumThreads()); + std::vector buf(cplan.work_size); + cplan.work_data = buf.data(); // compute ggml_graph_compute(&graph, &cplan); - - // free - free(cplan.work_data); } void FullyConnectedLayer::fullyConnected16x1Float32() diff --git a/runtime/onert/backend/cpu/ops/GatherLayer.cc b/runtime/onert/backend/cpu/ops/GatherLayer.cc index 525a976b6c7..d445c721d66 100644 --- a/runtime/onert/backend/cpu/ops/GatherLayer.cc +++ b/runtime/onert/backend/cpu/ops/GatherLayer.cc @@ -114,13 +114,11 @@ void GatherLayer::runByGGMLQuantInputType() // get cplan auto cplan = ggml_graph_plan(&graph, _ctx->maxNumThreads()); - cplan.work_data = (uint8_t *)(malloc(cplan.work_size)); + std::vector buf(cplan.work_size); + cplan.work_data = buf.data(); // compute ggml_graph_compute(&graph, &cplan); - - // free - free(cplan.work_data); } void GatherLayer::run()