Skip to content

Commit fd64695

Browse files
committed
examples : refactor build info prints into print_build_info
1 parent cf9b084 commit fd64695

File tree

12 files changed

+12
-19
lines changed

12 files changed

+12
-19
lines changed

Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -431,7 +431,7 @@ main: examples/main/main.cpp build-info.h ggml.
431431
@echo '==== Run ./main -h for help. ===='
432432
@echo
433433

434-
simple: examples/simple/simple.cpp build-info.h ggml.o llama.o common.o $(OBJS)
434+
simple: examples/simple/simple.cpp ggml.o llama.o common.o $(OBJS)
435435
$(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS)
436436

437437
quantize: examples/quantize/quantize.cpp build-info.h ggml.o llama.o $(OBJS)

common/common.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,10 @@
2020
#define DIRECTORY_SEPARATOR '/'
2121
#endif // _WIN32
2222

23+
#define print_build_info() do {
24+
fprintf(stderr, "%s: build = %d (%s)\n", __func__, BUILD_NUMBER, BUILD_COMMIT); \
25+
} while (0)
26+
2327
//
2428
// CLI argument parsing
2529
//

examples/beam-search/beam-search.cpp

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55
#include "common.h"
66
#include "llama.h"
7-
#include "build-info.h"
87

98
#include <cassert>
109
#include <cinttypes>

examples/benchmark/benchmark-matmult.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "ggml.h"
2-
#include "build-info.h"
32

43
#include <locale.h>
54
#include <assert.h>
@@ -99,7 +98,7 @@ int main(int argc, char ** argv) {
9998
exit(1);
10099
}
101100

102-
fprintf(stderr, "%s: build = %d (%s)\n", __func__, BUILD_NUMBER, BUILD_COMMIT);
101+
print_build_info();
103102
printf("Starting Test\n");
104103

105104
// create the ggml context

examples/embd-input/embd-input-lib.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ struct MyModel* create_mymodel(int argc, char ** argv) {
2727
return nullptr;
2828
}
2929

30-
fprintf(stderr, "%s: build = %d (%s)\n", __func__, BUILD_NUMBER, BUILD_COMMIT);
30+
print_build_info();
3131

3232
if (params.seed == LLAMA_DEFAULT_SEED) {
3333
params.seed = uint32_t(time(NULL));

examples/embd-input/embd-input.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33

44
#include "common.h"
55
#include "llama.h"
6-
#include "build-info.h"
76

87
extern "C" {
98

examples/embedding/embedding.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "common.h"
22
#include "llama.h"
3-
#include "build-info.h"
43

54
#include <ctime>
65

@@ -22,7 +21,7 @@ int main(int argc, char ** argv) {
2221
"expect poor results\n", __func__, params.n_ctx);
2322
}
2423

25-
fprintf(stderr, "%s: build = %d (%s)\n", __func__, BUILD_NUMBER, BUILD_COMMIT);
24+
print_build_info();
2625

2726
if (params.seed == LLAMA_DEFAULT_SEED) {
2827
params.seed = time(NULL);

examples/perplexity/perplexity.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "common.h"
22
#include "llama.h"
3-
#include "build-info.h"
43

54
#include <cmath>
65
#include <cstdio>
@@ -673,7 +672,7 @@ int main(int argc, char ** argv) {
673672
"expect poor results\n", __func__, params.n_ctx);
674673
}
675674

676-
fprintf(stderr, "%s: build = %d (%s)\n", __func__, BUILD_NUMBER, BUILD_COMMIT);
675+
print_build_info();
677676

678677
if (params.seed == LLAMA_DEFAULT_SEED) {
679678
params.seed = time(NULL);

examples/quantize-stats/quantize-stats.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
#include "ggml.h"
2-
#include "build-info.h"
32

43
#define LLAMA_API_INTERNAL
54
#include "llama.h"
@@ -314,7 +313,7 @@ int main(int argc, char ** argv) {
314313
return 1;
315314
}
316315

317-
fprintf(stderr, "%s: build = %d (%s)\n", __func__, BUILD_NUMBER, BUILD_COMMIT);
316+
print_build_info();
318317

319318
// load the model
320319
fprintf(stderr, "Loading model\n");

examples/quantize/quantize.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
#include "build-info.h"
2-
31
#include "llama.h"
42

53
#include <cstdio>
@@ -162,7 +160,7 @@ int main(int argc, char ** argv) {
162160
}
163161
}
164162

165-
fprintf(stderr, "%s: build = %d (%s)\n", __func__, BUILD_NUMBER, BUILD_COMMIT);
163+
print_build_info();
166164

167165
fprintf(stderr, "%s: quantizing '%s' to '%s' as %s", __func__, fname_inp.c_str(), fname_out.c_str(), ftype_str.c_str());
168166
if (params.nthread > 0) {

examples/save-load-state/save-load-state.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#include "common.h"
22
#include "llama.h"
3-
#include "build-info.h"
43

54
#include <vector>
65
#include <cstdio>
@@ -17,7 +16,7 @@ int main(int argc, char ** argv) {
1716
return 1;
1817
}
1918

20-
fprintf(stderr, "%s: build = %d (%s)\n", __func__, BUILD_NUMBER, BUILD_COMMIT);
19+
print_build_info();
2120

2221
if (params.n_predict < 0) {
2322
params.n_predict = 16;

examples/simple/simple.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,6 @@
22
#define _GNU_SOURCE
33
#endif
44

5-
#include "build-info.h"
6-
75
#include "common.h"
86
#include "llama.h"
97

0 commit comments

Comments
 (0)