Ver código fonte

tests : fix test-opt with GGML_BACKEND_DL (#15599)

Diego Devesa 4 meses atrás
pai
commit
bcbddcd54f
1 arquivos alterados com 6 adições e 5 exclusões
  1. 6 5
      tests/test-opt.cpp

+ 6 - 5
tests/test-opt.cpp

@@ -3,7 +3,6 @@
 #include "ggml.h"
 #include "ggml.h"
 #include "ggml-alloc.h"
 #include "ggml-alloc.h"
 #include "ggml-backend.h"
 #include "ggml-backend.h"
-#include "ggml-cpu.h"
 #include "ggml-opt.h"
 #include "ggml-opt.h"
 
 
 #include <cmath>
 #include <cmath>
@@ -899,6 +898,7 @@ static std::pair<int, int> test_backend(
 
 
 int main(void) {
 int main(void) {
     ggml_log_set(nullptr, nullptr);
     ggml_log_set(nullptr, nullptr);
+    ggml_backend_load_all();
     const size_t dev_count = ggml_backend_dev_count();
     const size_t dev_count = ggml_backend_dev_count();
     printf("Testing %zu devices\n\n", dev_count);
     printf("Testing %zu devices\n\n", dev_count);
     size_t n_ok = 0;
     size_t n_ok = 0;
@@ -911,11 +911,12 @@ int main(void) {
 
 
         ggml_backend_t backend = ggml_backend_dev_init(devs[i], NULL);
         ggml_backend_t backend = ggml_backend_dev_init(devs[i], NULL);
         GGML_ASSERT(backend != NULL);
         GGML_ASSERT(backend != NULL);
-#ifndef _MSC_VER
-        if (ggml_backend_is_cpu(backend)) {
-            ggml_backend_cpu_set_n_threads(backend, std::thread::hardware_concurrency() / 2);
+
+        auto * reg = ggml_backend_dev_backend_reg(devs[i]);
+        auto ggml_backend_set_n_threads_fn = (ggml_backend_set_n_threads_t) ggml_backend_reg_get_proc_address(reg, "ggml_backend_set_n_threads");
+        if (ggml_backend_set_n_threads_fn) {
+            ggml_backend_set_n_threads_fn(backend, std::thread::hardware_concurrency() / 2);
         }
         }
-#endif
         backends.push_back(backend);
         backends.push_back(backend);
     }
     }