jklincn commited on
Commit
66d5b20
·
1 Parent(s): e3908a2

ggml-backend : fix backend search path (llama/12330)

Browse files

* Fix backend search path

* replace .native() with '/'

* reverted .native()

Files changed (1) hide show
  1. ggml/src/ggml-backend-reg.cpp +5 -5
ggml/src/ggml-backend-reg.cpp CHANGED
@@ -497,7 +497,7 @@ static ggml_backend_reg_t ggml_backend_load_best(const char * name, bool silent,
497
  search_paths.push_back(get_executable_path());
498
  search_paths.push_back(fs::current_path());
499
  } else {
500
- search_paths.push_back(user_search_path);
501
  }
502
 
503
  int best_score = 0;
@@ -511,9 +511,9 @@ static ggml_backend_reg_t ggml_backend_load_best(const char * name, bool silent,
511
  fs::directory_iterator dir_it(search_path, fs::directory_options::skip_permission_denied);
512
  for (const auto & entry : dir_it) {
513
  if (entry.is_regular_file()) {
514
- auto filename = entry.path().filename().native();
515
- auto ext = entry.path().extension().native();
516
- if (filename.find(file_prefix) == 0 && ext == file_extension) {
517
  dl_handle_ptr handle { dl_load_library(entry) };
518
  if (!handle && !silent) {
519
  GGML_LOG_ERROR("%s: failed to load %s\n", __func__, path_str(entry.path()).c_str());
@@ -544,7 +544,7 @@ static ggml_backend_reg_t ggml_backend_load_best(const char * name, bool silent,
544
  // try to load the base backend
545
  for (const auto & search_path : search_paths) {
546
  fs::path filename = backend_filename_prefix().native() + name_path.native() + backend_filename_extension().native();
547
- fs::path path = search_path.native() + filename.native();
548
  if (fs::exists(path)) {
549
  return get_reg().load_backend(path, silent);
550
  }
 
497
  search_paths.push_back(get_executable_path());
498
  search_paths.push_back(fs::current_path());
499
  } else {
500
+ search_paths.push_back(fs::u8path(user_search_path));
501
  }
502
 
503
  int best_score = 0;
 
511
  fs::directory_iterator dir_it(search_path, fs::directory_options::skip_permission_denied);
512
  for (const auto & entry : dir_it) {
513
  if (entry.is_regular_file()) {
514
+ auto filename = entry.path().filename();
515
+ auto ext = entry.path().extension();
516
+ if (filename.native().find(file_prefix) == 0 && ext == file_extension) {
517
  dl_handle_ptr handle { dl_load_library(entry) };
518
  if (!handle && !silent) {
519
  GGML_LOG_ERROR("%s: failed to load %s\n", __func__, path_str(entry.path()).c_str());
 
544
  // try to load the base backend
545
  for (const auto & search_path : search_paths) {
546
  fs::path filename = backend_filename_prefix().native() + name_path.native() + backend_filename_extension().native();
547
+ fs::path path = search_path / filename;
548
  if (fs::exists(path)) {
549
  return get_reg().load_backend(path, silent);
550
  }