-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefile
67 lines (49 loc) · 1.93 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
CC := gcc
CFLAGS := -Wall -Wextra -pedantic
PY := python3
C_FORMAT := clang-format
PY_FORMAT := autopep8
LIB_DIR := lib
EXAMPLE_DIR := examples
SCRIPTS_DIR := scripts
BENCHMARK_DIR := $(SCRIPTS_DIR)/benchmarks
TEST_DIR := tests
DOWNLOAD_DATA_DIR := $(SCRIPTS_DIR)/download_datasets
LIB_C_FILES := $(wildcard $(LIB_DIR)/*.c)
LIB_H_FILES := $(wildcard $(LIB_DIR)/*.h)
EXAMPLE_FILES := $(wildcard $(EXAMPLE_DIR)/*.c)
TEST_FILES := $(wildcard $(TEST_DIR)/*.c)
TEST_HEADER := $(TEST_DIR)/tests.h
DOWNLOAD_SCRIPTS := $(wildcard $(DOWNLOAD_DATA_DIR)/*.py)
C_FILES := $(shell find . -name '*.c' -not -path "./env/*")
H_FILES := $(shell find . -name '*.h' -not -path "./env/*")
PY_FILES := $(shell find . -name '*.py' -not -path "./env/*")
BENCH_LEARN_FILE := $(BENCHMARK_DIR)/bench_learn.py
BENCH_MAT_MUL_FILE := $(BENCHMARK_DIR)/bench_mat_mul.c
examples := mnist_vanilla mnist_conv mnist_mix xor full_adder iris lin_reg mnist_conv_tiny
downloaders := get_mnist
.DEFAULT_GOAL := all
all: $(examples)
$(examples): $(LIB_C_FILES) $(LIB_H_FILES) $(EXAMPLE_FILES)
$(CC) $(CFLAGS) -o $@ $(LIB_C_FILES) $(EXAMPLE_DIR)/[email protected]
run_%: %
./$<
tests := autodiff correlation forward_dense
$(tests): $(LIB_C_FILES) $(LIB_H_FILES) $(TEST_FILES) $(TEST_HEADER)
$(CC) $(CFLAGS) -o $@ $(TEST_DIR)/[email protected] $(LIB_C_FILES)
test_%: %
$(PY) $(TEST_DIR)/$<.py
test: $(addprefix test_, $(tests))
pip_update:
pip --disable-pip-version-check list --outdated --format=json | python -c "import json, sys; print('\n'.join([x['name'] for x in json.load(sys.stdin)]))" | xargs -n1 pip install -U
pip freeze > requirements.txt
$(downloaders): $(DOWNLOAD_SCRIPTS)
$(PY) $(DOWNLOAD_DATA_DIR)/[email protected]
bench_learn: iris $(BENCH_LEARN_FILE)
$(PY) $(BENCH_LEARN_FILE)
format: $(C_FILES) $(H_FILES) $(PY_FILES)
$(C_FORMAT) -style="{BasedOnStyle: llvm, IndentWidth: 4, TabWidth: 4, UseTab: Never}" -i $(C_FILES) $(H_FILES)
$(PY_FORMAT) --in-place $(PY_FILES)
clean:
rm -f $(examples) $(tests)
rm -f model