Skip to content

Commit bcbddcd

Browse files
authored
tests : fix test-opt with GGML_BACKEND_DL (ggml-org#15599)
1 parent 8b69686 commit bcbddcd

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

tests/test-opt.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
#include "ggml.h"
44
#include "ggml-alloc.h"
55
#include "ggml-backend.h"
6-
#include "ggml-cpu.h"
76
#include "ggml-opt.h"
87

98
#include <cmath>
@@ -899,6 +898,7 @@ static std::pair<int, int> test_backend(
899898

900899
int main(void) {
901900
ggml_log_set(nullptr, nullptr);
901+
ggml_backend_load_all();
902902
const size_t dev_count = ggml_backend_dev_count();
903903
printf("Testing %zu devices\n\n", dev_count);
904904
size_t n_ok = 0;
@@ -911,11 +911,12 @@ int main(void) {
911911

912912
ggml_backend_t backend = ggml_backend_dev_init(devs[i], NULL);
913913
GGML_ASSERT(backend != NULL);
914-
#ifndef _MSC_VER
915-
if (ggml_backend_is_cpu(backend)) {
916-
ggml_backend_cpu_set_n_threads(backend, std::thread::hardware_concurrency() / 2);
914+
915+
auto * reg = ggml_backend_dev_backend_reg(devs[i]);
916+
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");
917+
if (ggml_backend_set_n_threads_fn) {
918+
ggml_backend_set_n_threads_fn(backend, std::thread::hardware_concurrency() / 2);
917919
}
918-
#endif
919920
backends.push_back(backend);
920921
}
921922

0 commit comments

Comments
 (0)