-
Notifications
You must be signed in to change notification settings - Fork 64
/
Makefile
149 lines (119 loc) · 3.86 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
TARGET = llama
# $(shell cat VERSION)
VERSION = v1.4.0
OS = linux
ARCH = amd64
PACKAGE = github.com/gotzmann/$(TARGET)
.DEFAULT_GOAL := build-osx
.PHONY: \
clean \
tools \
test \
coverage \
fmt \
build \
doc \
release \
all: tools fmt build test release
print-%:
@echo $* = $($*)
$(TARGET)-build-linux:
CGO_ENABLED=0 GOOS=$(OS) GOARCH=$(ARCH) go build -ldflags \
"-X $(PACKAGE)/version=$(VERSION)" \
-v -o $(CURDIR)/$(TARGET) .
$(TARGET)-build-darwin:
CGO_ENABLED=0 GOOS=darwin GOARCH=arm64 go build -ldflags \
"-X $(PACKAGE)/version=$(VERSION)" \
-v -o $(CURDIR)/$(TARGET) .
build: $(TARGET)-build-linux
build-osx: $(TARGET)-build-darwin
clean:
rm -f $(PACKAGE)-linux-amd64
rm -f $(PACKAGE)-darwin-arm64
rm -f coverage.txt
tools:
go get github.com/axw/gocov/gocov
go get github.com/matm/gocov-html
go get github.com/golangci/golangci-lint/cmd/golangci-lint
go get github.com/gordonklaus/ineffassign
go get honnef.co/go/tools/cmd/staticcheck
go get github.com/client9/misspell/cmd/misspell
test: test_ineffassign \
test_staticcheck \
test_misspell \
test_govet \
test_gotest_race \
test_gotest_cover
fmt:
go fmt ./...
coverage:
gocov test ./... > $(CURDIR)/coverage.out 2>/dev/null
gocov report $(CURDIR)/coverage.out
if test -z "$$CI"; then \
gocov-html $(CURDIR)/coverage.out > $(CURDIR)/coverage.html; \
if which open &>/dev/null; then \
open $(CURDIR)/coverage.html; \
fi; \
fi
test_ineffassign:
@echo "test: ineffassign"
@ineffassign pkg/llama/*.go || (echo "ineffassign failed"; exit 1)
@ineffassign pkg/ml/*.go || (echo "ineffassign failed"; exit 1)
@echo "test: ok"
test_staticcheck:
@echo "test: staticcheck"
@staticcheck pkg/llama/*.go || (echo "staticcheck failed"; exit 1)
@staticcheck pkg/ml/*.go || (echo "staticcheck failed"; exit 1)
@echo "test: ok"
test_misspell:
@echo "test: misspell"
@misspell pkg/llama/*.go || (echo "misspell failed"; exit 1)
@misspell pkg/ml/*.go || (echo "misspell failed"; exit 1)
@echo "test: ok"
test_govet:
@echo "test: go vet"
@go vet pkg/llama/*.go|| (echo "go vet failed"; exit 1)
@go vet pkg/ml/*.go || (echo "go vet failed"; exit 1)
@echo "test: ok"
test_gosec:
@echo "test: gosec"
@gosec pkg/llama/ . || (echo "gosec failed"; exit 1)
@gosec pkg/ml/ . || (echo "gosec failed"; exit 1)
@echo "test: ok"
test_gotest_race:
@echo "test: go test -race"
@go test -race -coverprofile=coverage.txt -covermode=atomic ./ || (echo "go test -race failed"; exit 1)
@echo "test: ok"
test_gotest_cover:
@echo "test: go test -cover"
@go test -cover ./ || (echo "go test -cover failed"; exit 1)
@echo "test: ok"
testbadge:
@echo "Running tests to update readme with badge coverage"
@go tool cover -func=coverage.out -o=coverage.out
@gobadge -filename=coverage.out -link https://github.com/gotzmann/llama.go/actions/workflows/coverage.yml
doc:
@echo "doc: http://localhost:8080/pkg/github.com/gotzmann/llama.go"
godoc -http=:8080 -index
release:
@echo "release: $(VERSION)"
@git tag -a $(VERSION) -m "Release $(VERSION)"
@git push origin $(VERSION)
@echo "release: ok"
convert16:
python3 ./scripts/convert.py ./LLaMA/7B/ 1
convert32:
python3 ./scripts/convert.py ./LLaMA/7B/ 0
quantize:
./quantize ~/models/7B/ggml-model-f32.bin ~/models/7B/ggml-model-q4_0.bin 2
int4:
make -j && ./main -m ./models/7B/ggml-model-q4_0.bin -p "How to create conversational AI:" -n 512
fp16:
make -j && ./main -m ./models/7B/ggml-model-f16.bin -p "How to create conversational AI:" -n 512
pprof:
go tool pprof -pdf cpu.pprof > cpu.pdf
.PHONY: builds
builds:
GOOS=windows GOARCH=amd64 go build -o ./builds/llama-go-$(VERSION).exe -ldflags "-s -w" main.go
GOOS=darwin GOARCH=amd64 go build -o ./builds/llama-go-$(VERSION)-macos -ldflags "-s -w" main.go
GOOS=linux GOARCH=amd64 go build -o ./builds/llama-go-$(VERSION)-linux -ldflags "-s -w" main.go