Skip to content

Commit 4defcf2

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 <[email protected]>
1 parent dd3a6ce commit 4defcf2

File tree

5 files changed

+425
-0
lines changed

5 files changed

+425
-0
lines changed

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 \
@@ -1382,6 +1383,11 @@ llama-infill: examples/infill/infill.cpp \
13821383
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
13831384
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
13841385

1386+
llama-run: examples/run/run.cpp \
1387+
$(OBJ_ALL)
1388+
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)
1389+
$(CXX) $(CXXFLAGS) $(filter-out %.h $<,$^) $(call GET_OBJ_FILE, $<) -o $@ $(LDFLAGS)
1390+
13851391
llama-simple: examples/simple/simple.cpp \
13861392
$(OBJ_ALL)
13871393
$(CXX) $(CXXFLAGS) -c $< -o $(call GET_OBJ_FILE, $<)

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)

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)

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)