Skip to content

Commit 54e3bc7

Browse files
jpodivinggerganov
andauthored
make : add new target for test binaries (#2244)
Programs in the tests directory are now build with target tests and placed in the same location. * clean target was expanded to remove new binaries * test target binaries are listed in a variable * Locations of binaries were added to the .gitignore Signed-off-by: Jiri Podivin <[email protected]> Co-authored-by: Georgi Gerganov <[email protected]>
1 parent 019fe25 commit 54e3bc7

File tree

2 files changed

+35
-4
lines changed

2 files changed

+35
-4
lines changed

.gitignore

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,3 +61,12 @@ qnt-*.txt
6161
perf-*.txt
6262

6363
examples/jeopardy/results.txt
64+
65+
# Test binaries
66+
tests/test-double-float
67+
tests/test-grad0
68+
tests/test-opt
69+
tests/test-quantize-fns
70+
tests/test-quantize-perf
71+
tests/test-sampling
72+
tests/test-tokenizer-0

Makefile

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
11
# Define the default target now so that it is always the first target
22
BUILD_TARGETS = main quantize quantize-stats perplexity embedding vdot train-text-from-scratch simple server embd-input-test
33

4+
# Binaries only useful for tests
5+
TEST_TARGETS = tests/test-double-float tests/test-grad0 tests/test-opt tests/test-quantize-fns tests/test-quantize-perf tests/test-sampling tests/test-tokenizer-0
6+
47
default: $(BUILD_TARGETS)
58

69
ifndef UNAME_S
@@ -316,7 +319,7 @@ libllama.so: llama.o ggml.o $(OBJS)
316319
$(CXX) $(CXXFLAGS) -shared -fPIC -o $@ $^ $(LDFLAGS)
317320

318321
clean:
319-
rm -vf *.o *.so *.dll main quantize quantize-stats perplexity embedding benchmark-matmult save-load-state server simple vdot train-text-from-scratch embd-input-test build-info.h
322+
rm -vf *.o *.so *.dll main quantize quantize-stats perplexity embedding benchmark-matmult save-load-state server simple vdot train-text-from-scratch embd-input-test build-info.h $(TEST_TARGETS)
320323

321324
#
322325
# Examples
@@ -371,13 +374,32 @@ build-info.h: $(wildcard .git/index) scripts/build-info.sh
371374
# Tests
372375
#
373376

377+
tests: $(TEST_TARGETS)
378+
374379
benchmark-matmult: examples/benchmark/benchmark-matmult.cpp build-info.h ggml.o $(OBJS)
375380
$(CXX) $(CXXFLAGS) $(filter-out %.h,$^) -o $@ $(LDFLAGS)
376381
./$@
377382

378383
vdot: pocs/vdot/vdot.cpp ggml.o $(OBJS)
379384
$(CXX) $(CXXFLAGS) $^ -o $@ $(LDFLAGS)
380385

381-
.PHONY: tests clean
382-
tests:
383-
bash ./tests/run-tests.sh
386+
tests/test-double-float: tests/test-double-float.c build-info.h ggml.o llama.o common.o $(OBJS)
387+
$(CXX) $(CXXFLAGS) $(filter-out %.txt,$^) -o $@ $(LDFLAGS)
388+
389+
tests/test-grad0: tests/test-grad0.c build-info.h ggml.o llama.o common.o $(OBJS)
390+
$(CXX) $(CXXFLAGS) $(filter-out %.txt,$^) -o $@ $(LDFLAGS)
391+
392+
tests/test-opt: tests/test-opt.c build-info.h ggml.o llama.o common.o $(OBJS)
393+
$(CXX) $(CXXFLAGS) $(filter-out %.txt,$^) -o $@ $(LDFLAGS)
394+
395+
tests/test-quantize-fns: tests/test-quantize-fns.cpp build-info.h ggml.o llama.o common.o $(OBJS)
396+
$(CXX) $(CXXFLAGS) $(filter-out %.txt,$^) -o $@ $(LDFLAGS)
397+
398+
tests/test-quantize-perf: tests/test-quantize-perf.cpp build-info.h ggml.o llama.o common.o $(OBJS)
399+
$(CXX) $(CXXFLAGS) $(filter-out %.txt,$^) -o $@ $(LDFLAGS)
400+
401+
tests/test-sampling: tests/test-sampling.cpp build-info.h ggml.o llama.o common.o $(OBJS)
402+
$(CXX) $(CXXFLAGS) $(filter-out %.txt,$^) -o $@ $(LDFLAGS)
403+
404+
tests/test-tokenizer-0: tests/test-tokenizer-0.cpp build-info.h ggml.o llama.o common.o $(OBJS)
405+
$(CXX) $(CXXFLAGS) $(filter-out %.txt,$^) -o $@ $(LDFLAGS)

0 commit comments

Comments
 (0)