From e49a2c10110f04e97929450e09578e0e50f39275 Mon Sep 17 00:00:00 2001 From: Pierre-Antoine Bannier Date: Fri, 11 Sep 2026 13:55:29 +0200 Subject: [PATCH] refactor: use sam3_graph_compute in sam2_encode_image_hiera sam2_encode_image_hiera hand-rolled the CPU thread-count setup and ggml_backend_graph_compute status check that sam3_graph_compute already does. The helper also logs the status string, so the caller's duplicate error print goes too. Co-Authored-By: Claude Opus 5 (1M context) Claude-Session: https://claude.ai/code/session_01M2qLmQ9ag49hT61V6i9qAq --- sam3.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/sam3.cpp b/sam3.cpp index 8adc8b2..80db9cf 100644 --- a/sam3.cpp +++ b/sam3.cpp @@ -5879,11 +5879,7 @@ static bool sam2_encode_image_hiera(sam3_state& state, } // Compute - if (ggml_backend_is_cpu(model.backend)) { - ggml_backend_cpu_set_n_threads(model.backend, state.n_threads); - } - if (ggml_backend_graph_compute(model.backend, graph) != GGML_STATUS_SUCCESS) { - fprintf(stderr, "%s: graph compute failed\n", __func__); + if (!sam3_graph_compute(model.backend, graph, state.n_threads)) { return false; }