Skip to content

Commit a9054cb

Browse files
committed
Introduce llama-run
It's like simple-chat but it uses smart pointers to avoid manual memory cleanups. Less memory leaks in the code now. Avoid printing multiple dots. Split code into smaller functions. Uses no exception handling. Signed-off-by: Eric Curtin <ecurtin@redhat.com>
1 parent cce5a90 commit a9054cb

File tree

7 files changed

+456
-2
lines changed

7 files changed

+456
-2
lines changed

Diff for: CMakeLists.txt

+5-2
Original file line numberDiff line numberDiff line change
@@ -163,8 +163,11 @@ if (GGML_TARGET_DEFINES)
163163
list(APPEND GGML_TRANSIENT_DEFINES ${GGML_TARGET_DEFINES})
164164
endif()
165165
get_target_property(GGML_LINK_LIBRARIES ggml LINK_LIBRARIES)
166-
167-
set_target_properties(llama PROPERTIES PUBLIC_HEADER ${CMAKE_CURRENT_SOURCE_DIR}/include/llama.h)
166+
# all public headers
167+
set(LLAMA_PUBLIC_HEADERS
168+
${CMAKE_CURRENT_SOURCE_DIR}/include/llama.h
169+
${CMAKE_CURRENT_SOURCE_DIR}/include/llama-cpp.h)
170+
set_target_properties(llama PROPERTIES PUBLIC_HEADER "${LLAMA_PUBLIC_HEADERS}")
168171
install(TARGETS llama LIBRARY PUBLIC_HEADER)
169172

170173
configure_package_config_file(

Diff for: Makefile

+6
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ BUILD_TARGETS = \
3434
llama-server \
3535
llama-simple \
3636
llama-simple-chat \
37+
llama-run \
3738
llama-speculative \
3839
llama-tokenize \
3940
llama-vdot \
@@ -1165,6 +1166,11 @@ llama-infill: examples/infill/infill.cpp \
11651166
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
11661167
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
11671168

1169+
llama-run: examples/run/run.cpp \
1170+
$(OBJ_ALL)
1171+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1172+
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1173+
11681174
llama-simple: examples/simple/simple.cpp \
11691175
$(OBJ_ALL)
11701176
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)

Diff for: examples/CMakeLists.txt

+1
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ else()
4747
add_subdirectory(sycl)
4848
endif()
4949
add_subdirectory(save-load-state)
50+
add_subdirectory(run)
5051
add_subdirectory(simple)
5152
add_subdirectory(simple-chat)
5253
add_subdirectory(speculative)

Diff for: examples/run/CMakeLists.txt

+5
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
set(TARGET llama-run)
2+
add_executable(${TARGET} run.cpp)
3+
install(TARGETS ${TARGET} RUNTIME)
4+
target_link_libraries(${TARGET} PRIVATE llama ${CMAKE_THREAD_LIBS_INIT})
5+
target_compile_features(${TARGET} PRIVATE cxx_std_11)

Diff for: examples/run/README.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# llama.cpp/example/run
2+
3+
The purpose of this example is to demonstrate a minimal usage of llama.cpp for running models.
4+
5+
```bash
6+
./llama-run Meta-Llama-3.1-8B-Instruct.gguf
7+
...

0 commit comments

Comments
 (0)