Skip to content

Commit 7844941

Browse files
committed
Adaptation of model name extraction for different systems
1 parent f8a88ab commit 7844941

File tree

1 file changed

+6
-8
lines changed

1 file changed

+6
-8
lines changed

examples/llama-bench/llama-bench.cpp

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
#include "ggml.h"
2323
#include "llama.h"
2424
#include "llama-context.h"
25+
#include <filesystem>
2526

2627
#ifdef _WIN32
2728
# define WIN32_LEAN_AND_MEAN
@@ -879,14 +880,11 @@ static std::vector<cmd_params_instance> get_cmd_params_instances(const cmd_param
879880
* @param path The input model path information.
880881
* @return Full name of the model.
881882
*/
882-
static std::string get_modelfile_name(const std::string & path) {
883-
size_t index = path.find_last_of('/');
884-
if (index != std::string::npos) {
885-
std::string filename = path.substr(index + 1);
886-
return filename;
887-
} else {
888-
return path;
889-
}
883+
static std::string get_modelfile_name(const std::string & path_str) {
884+
namespace fs = std::filesystem;
885+
fs::path path = path_str;
886+
887+
return path.filename();
890888
}
891889

892890
struct test {

0 commit comments

Comments
 (0)