Skip to content

Commit 612599f

Browse files
slarenarthw
authored andcommitted
ggml : move CPU backend to a separate file (ggml-org#10144)
1 parent 532bcd0 commit 612599f

32 files changed

+19978
-24576
lines changed

Makefile

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
# Define the default target now so that it is always the first target
22
BUILD_TARGETS = \
33
libllava.a \
4-
llama-baby-llama \
54
llama-batched \
65
llama-batched-bench \
76
llama-bench \
@@ -56,14 +55,14 @@ TEST_TARGETS = \
5655
tests/test-llama-grammar \
5756
tests/test-log \
5857
tests/test-model-load-cancel \
59-
tests/test-opt \
6058
tests/test-quantize-fns \
6159
tests/test-quantize-perf \
6260
tests/test-rope \
6361
tests/test-sampling \
6462
tests/test-tokenizer-0 \
6563
tests/test-tokenizer-1-bpe \
6664
tests/test-tokenizer-1-spm
65+
# tests/test-opt \
6766
6867
# Legacy build targets that were renamed in #7809, but should still be removed when the project is cleaned
6968
LEGACY_TARGETS_CLEAN = main quantize quantize-stats perplexity imatrix embedding vdot q8dot convert-llama2c-to-ggml \
@@ -915,6 +914,7 @@ endif # GGML_METAL
915914

916915
OBJ_GGML += \
917916
ggml/src/ggml.o \
917+
ggml/src/ggml-cpu.o \
918918
ggml/src/ggml-alloc.o \
919919
ggml/src/ggml-backend.o \
920920
ggml/src/ggml-quants.o \
@@ -935,7 +935,6 @@ OBJ_COMMON = \
935935
common/console.o \
936936
common/ngram-cache.o \
937937
common/sampling.o \
938-
common/train.o \
939938
common/build-info.o \
940939
common/json-schema-to-grammar.o
941940

@@ -1047,6 +1046,12 @@ ggml/src/ggml.o: \
10471046
ggml/include/ggml.h
10481047
$(CC) $(CFLAGS) -c $< -o $@
10491048

1049+
ggml/src/ggml-cpu.o: \
1050+
ggml/src/ggml-cpu.c \
1051+
ggml/include/ggml.h \
1052+
ggml/src/ggml-common.h
1053+
$(CC) $(CFLAGS) -c $< -o $@
1054+
10501055
ggml/src/ggml-alloc.o: \
10511056
ggml/src/ggml-alloc.c \
10521057
ggml/include/ggml.h \
@@ -1212,11 +1217,6 @@ common/json-schema-to-grammar.o: \
12121217
common/json-schema-to-grammar.h
12131218
$(CXX) $(CXXFLAGS) -c $< -o $@
12141219

1215-
common/train.o: \
1216-
common/train.cpp \
1217-
common/train.h
1218-
$(CXX) $(CXXFLAGS) -c $< -o $@
1219-
12201220
common/ngram-cache.o: \
12211221
common/ngram-cache.cpp \
12221222
common/ngram-cache.h
@@ -1389,11 +1389,6 @@ llama-bench: examples/llama-bench/llama-bench.cpp \
13891389
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
13901390
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
13911391

1392-
llama-baby-llama: examples/baby-llama/baby-llama.cpp \
1393-
$(OBJ_ALL)
1394-
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1395-
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1396-
13971392
llama-export-lora: examples/export-lora/export-lora.cpp \
13981393
$(OBJ_ALL)
13991394
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)

Package.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ var sources = [
1010
"src/unicode.cpp",
1111
"src/unicode-data.cpp",
1212
"ggml/src/ggml.c",
13+
"ggml/src/ggml-cpu.c",
1314
"ggml/src/ggml-alloc.c",
1415
"ggml/src/ggml-backend.cpp",
1516
"ggml/src/ggml-quants.c",

common/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@ add_library(${TARGET} STATIC
6666
ngram-cache.h
6767
sampling.cpp
6868
sampling.h
69-
train.cpp
70-
train.h
7169
)
7270

7371
if (BUILD_SHARED_LIBS)

common/common.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1951,6 +1951,8 @@ void yaml_dump_string_multiline(FILE * stream, const char * prop_name, const cha
19511951

19521952
void yaml_dump_non_result_info(FILE * stream, const common_params & params, const llama_context * lctx,
19531953
const std::string & timestamp, const std::vector<int> & prompt_tokens, const char * model_desc) {
1954+
ggml_cpu_init(); // some ARM features are detected at runtime
1955+
19541956
const auto & sparams = params.sparams;
19551957

19561958
fprintf(stream, "build_commit: %s\n", LLAMA_COMMIT);

0 commit comments

Comments
 (0)