Skip to content

Commit 2b3a27f

Browse files
authored
add test folder and cmakelists.txt for test (#4)
1 parent 7292e5b commit 2b3a27f

File tree

7 files changed

+39
-3
lines changed

7 files changed

+39
-3
lines changed

.gitignore

+2-1
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@
3131
*.out
3232
*.app
3333

34-
data/
34+
data/
35+
build/

.vscode/c_cpp_properties.json

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
"name": "Linux",
55
"includePath": [
66
"${workspaceFolder}/**",
7-
"${workspaceFolder}/ggml/**"
7+
"${workspaceFolder}/ggml/**",
8+
"${workspaceFolder}/src/**"
89
],
910
"defines": [],
10-
"compilerPath": "/usr/bin/gcc",
1111
"cStandard": "c17",
1212
"cppStandard": "gnu++17",
1313
"intelliSenseMode": "linux-gcc-x64"

.vscode/settings.json

+7
Original file line numberDiff line numberDiff line change
@@ -9,4 +9,11 @@
99
"editor.formatOnType": false
1010
},
1111
"yapf.importStrategy": "useBundled",
12+
"cmake.sourceDirectory": [
13+
"/media/E/lichunyu/bert.cpp",
14+
"/media/E/lichunyu/bert.cpp/cmake",
15+
"/media/E/lichunyu/bert.cpp/test/test_model_load"
16+
],
17+
"C_Cpp.default.compilerPath": "/usr/bin/g++-11",
18+
"cmake.configureOnOpen": true,
1219
}

cmake/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
cmake_minimum_required(VERSION 3.12)

src/bert.cpp

+3
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,11 @@
55
#include <fstream>
66

77
int bert_predict() {
8+
return 0;
89
};
910

1011
std::vector<int> bert_batch_predict() {
12+
return std::vector<int>{1, 2};
1113
};
1214

1315
bool bert_model_load(const std::string &fname, bert_model &model)
@@ -82,4 +84,5 @@ bool bert_model_load(const std::string &fname, bert_model &model)
8284
return false;
8385
}
8486
}
87+
return true;
8588
};

test/test_model_load/CMakeLists.txt

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
cmake_minimum_required(VERSION 3.12)
2+
project(test_model_load)
3+
4+
add_subdirectory(../../ggml ${CMAKE_CURRENT_BINARY_DIR}/ggml)
5+
6+
include_directories(../../src)
7+
8+
add_executable(test_model_load test_model_load.cpp ../../src/bert.cpp)
9+
10+
target_link_libraries(test_model_load ggml)
+14
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "bert.h"
2+
3+
#include <string>
4+
5+
int main(int argc, char **argv)
6+
{
7+
bert_model model;
8+
std::string fname = "/media/E/lichunyu/bert.cpp/data/ggml-model/ggml_model.gguf";
9+
if (!bert_model_load(fname, model))
10+
{
11+
fprintf(stderr, "%s: failed to load model from %s", __func__, fname.c_str());
12+
}
13+
return 0;
14+
}

0 commit comments

Comments
 (0)