Skip to content

Commit 9f40989

Browse files
authored
ggml : move CPU backend to a separate file (ggml-org#10144)
1 parent 08828a6 commit 9f40989

32 files changed

+19978
-24576
lines changed

Makefile

+8-13
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 \
@@ -916,6 +915,7 @@ endif # GGML_METAL
916915

917916
OBJ_GGML += \
918917
ggml/src/ggml.o \
918+
ggml/src/ggml-cpu.o \
919919
ggml/src/ggml-alloc.o \
920920
ggml/src/ggml-backend.o \
921921
ggml/src/ggml-quants.o \
@@ -936,7 +936,6 @@ OBJ_COMMON = \
936936
common/console.o \
937937
common/ngram-cache.o \
938938
common/sampling.o \
939-
common/train.o \
940939
common/build-info.o \
941940
common/json-schema-to-grammar.o
942941

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

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

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

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

Package.swift

+1
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

-2
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

+2
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)