This repository has been archived by the owner on Sep 5, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
78 lines (57 loc) · 1.98 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
LIQUID=stack exec -- liquid
STACK=stack
MODELS=$(patsubst train_%.py,models/%.hs,$(wildcard train_*.py))
BENCHMARK_START=76
BENCHMARK_STOP=100
BENCHMARK_STEP=1
BENCHMARK_IDS=$(shell seq $(BENCHMARK_START) $(BENCHMARK_STEP) $(BENCHMARK_STOP))
BENCHMARKS_HS=$(foreach n_params,$(BENCHMARK_IDS),bench/Random_$(n_params)_Linear_1.hs)
BENCHMARKS_H5=$(foreach n_params,$(BENCHMARK_IDS),bench/Random_$(n_params)_Linear_1.h5)
BENCHMARKS_H5_HD=$(word 1,$(BENCHMARKS_H5))
BENCHMARKS_H5_TL=$(wordlist 2,$(words $(BENCHMARKS_H5)),$(BENCHMARKS_H5))
.PHONY: build
build:
$(STACK) build --flag lazuli:liquidhaskell
.PHONY: test
test:
$(STACK) test
$(LIQUID) -isrc models/AND_Gate_2_Sigmoid_1.hs
.PHONY: clean
clean:
stack clean
.PHONY: train
train: $(MODELS)
models/:
mkdir -p models
models/%.h5: train_%.py | models/
python $<
models/%.hs: models/%.h5
python convert.py -i $< -o $@
.PHONY: benchmark
benchmark: bench/results.csv bench/results.json bench/results.md
bench/results.csv: $(BENCHMARKS_HS)
hyperfine -m 3 --export-csv bench/results.csv --export-json bench/results.json --export-markdown bench/results.md -P n_params $(BENCHMARK_START) $(BENCHMARK_STOP) -D $(BENCHMARK_STEP) '$(LIQUID) -isrc bench/Random_{n_params}_Linear_1.hs'
bench/results.json: bench/results.csv
@if test -f $@; then :; else \
rm -f bench/results.csv; \
$(MAKE) $(AM_MAKEFLAGS) bench/results.csv; \
fi
bench/results.md: bench/results.csv
@if test -f $@; then :; else \
rm -f bench/results.csv; \
$(MAKE) $(AM_MAKEFLAGS) bench/results.csv; \
fi
bench/:
mkdir -p bench
$(BENCHMARKS_H5_HD): mk_bench.py | bench/
python mk_bench.py --start=$(BENCHMARK_START) --stop=$(BENCHMARK_STOP) --step=$(BENCHMARK_STEP)
define BENCHMARK_H5_template
$(1): $(BENCHMARKS_H5_HD)
@if test -f $$@; then :; else \
rm -f $(BENCHMARKS_H5_HD); \
$(MAKE) $(AM_MAKEFLAGS) $(BENCHMARKS_H5_HD); \
fi
endef
$(foreach bm,$(BENCHMARKS_H5_TL),$(eval $(call BENCHMARK_H5_template,$(bm))))
bench/%.hs: bench/%.h5
python convert.py -i $< -o $@