Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit9f63b4f

Browse files
committed
Change ModelLoader::load_tensors() method read file by wide character path(wchar_t *) to support all language path.
1 parent0e64238 commit9f63b4f

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

‎model.cpp‎

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,33 @@
1414
#include"ggml/ggml-backend.h"
1515
#include"ggml/ggml.h"
1616

17+
18+
19+
#if defined(_MSC_VER)
20+
#include<Windows.h>
21+
// windows.h, naming conflict with micros: std::min, sdt::max, SDLogLevel::ERROR
22+
23+
#undef ERROR
24+
staticwchar_t*str2wstr(constchar* str) {
25+
size_t len =strlen(str) +1;
26+
wchar_t* wstr = (wchar_t*)malloc(len *sizeof(wchar_t));
27+
MultiByteToWideChar(CP_UTF8,0, str, (int)(len *sizeof(char)), wstr,
28+
(int)len);
29+
return wstr;
30+
};
31+
32+
//#include <stringapiset.h>
33+
// donot only include stringapiset.h, C1189 #error: "No Target Architecture"
34+
35+
#else// defined(_MSC_VER)
36+
37+
#endif// defined(_MSC_VER)
38+
39+
40+
41+
42+
43+
1744
#defineST_HEADER_SIZE_LEN8
1845

1946
uint64_tread_u64(uint8_t* buffer) {
@@ -1203,7 +1230,17 @@ bool ModelLoader::load_tensors(on_new_tensor_cb_t on_new_tensor_cb) {
12031230
std::string file_path = file_paths_[file_index];
12041231
LOG_DEBUG("loading tensors from %s", file_path.c_str());
12051232

1233+
1234+
#if defined(_MSC_VER)
1235+
constchar * c_file_path = file_path.c_str();
1236+
constwchar_t * c_w_file_path =str2wstr(c_file_path);
1237+
std::ifstreamfile(c_w_file_path, std::ios::binary);
1238+
delete c_w_file_path;
1239+
1240+
#else// defined(_MSC_VER)
12061241
std::ifstreamfile(file_path, std::ios::binary);
1242+
#endif// defined(_MSC_VER)
1243+
12071244
if (!file.is_open()) {
12081245
LOG_ERROR("failed to open '%s'", file_path.c_str());
12091246
returnfalse;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp