-
Notifications
You must be signed in to change notification settings - Fork 15
/
Makefile
96 lines (78 loc) · 2.47 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
VENV_PATH ?= venv
PYTHON ?= python
PYTHON_BINARY ?= python
PYTEST ?= pytest
PIP ?= pip
YAPF ?= yapf
TORCH_VERSION ?= torch==1.8.1 torchvision==0.9.1 torchaudio==0.8.1
DACE_VERSION ?=
UPDATE_PIP ?= python -m pip install --upgrade pip
SOURCE_FILES = daceml tests setup.py examples doc
ifeq ($(VENV_PATH),)
ACTIVATE =
else
ACTIVATE = . $(VENV_PATH)/bin/activate &&
endif
.PHONY: clean doc doctest test test-gpu codecov check-formatting check-formatting-names clean-dacecaches yapf
clean:
! test -d $(VENV_PATH) || rm -r $(VENV_PATH)
venv:
ifneq ($(VENV_PATH),)
test -d $(VENV_PATH) || echo "Creating new venv" && $(PYTHON) -m venv ./$(VENV_PATH)
endif
install: venv
ifneq ($(VENV_PATH),)
$(ACTIVATE) $(UPDATE_PIP)
endif
ifneq ($(DACE_VERSION),)
$(ACTIVATE) $(PIP) install $(DACE_VERSION)
endif
$(ACTIVATE) $(PIP) install $(TORCH_VERSION)
$(ACTIVATE) $(PIP) install -e .[testing,docs]
doc:
# suppress warnings in ONNXOps docstrings using grep -v
$(ACTIVATE) cd doc && make clean html 2>&1 \
| grep -v ".*daceml\/daceml\/onnx\/nodes\/onnx_op\.py:docstring of daceml\.onnx\.nodes\.onnx_op\.ONNX.*:[0-9]*: WARNING:"
doctest:
$(ACTIVATE) cd doc && make doctest
test:
$(ACTIVATE) $(PYTEST) $(PYTEST_ARGS) tests
test-onnx:
$(ACTIVATE) $(PYTEST) $(PYTEST_ARGS) tests/pure_expansions/test_onnx_cases.py
test-parallel:
$(ACTIVATE) $(PYTEST) $(PYTEST_ARGS) tests -n auto --dist loadfile
test-gpu:
$(ACTIVATE) $(PYTEST) $(PYTEST_ARGS) tests --gpu
test-intel-fpga:
$(ACTIVATE) $(PYTEST) $(PYTEST_ARGS) tests/torch/fpga/
test-xilinx:
$(ACTIVATE) $(PYTEST) $(PYTEST_ARGS) tests/torch/fpga/
codecov:
curl -s https://codecov.io/bash | bash
clean-dacecaches:
find . -name ".dacecache" -type d -not -path "*CMakeFiles*" -exec rm -r {} \; || true
check-formatting:
$(ACTIVATE) $(YAPF) \
--parallel \
--diff \
--recursive \
$(SOURCE_FILES) \
--exclude daceml/onnx/shape_inference/symbolic_shape_infer.py
# check for sdfg.view()
! git grep '\.view()' -- tests/** daceml/**
format:
@$(ACTIVATE) \
DIFF=$$($(YAPF) \
--parallel \
--diff \
--recursive \
$(SOURCE_FILES) \
--exclude daceml/onnx/shape_inference/symbolic_shape_infer.py); \
if [ -z "$$DIFF" ]; then \
echo "All files formatted correctly"; \
exit 0; \
fi; \
FILES=$$(echo "$$DIFF" | grep -oP '\+\+\+\s+\K.*(?=\s+\(reformatted\))') \
&& echo "Going to format:\n$$FILES" && echo -n "Ok? [y/N]" \
&& read ans && [ $${ans:-N} = y ] && echo "Formatting..." \
&& echo "$$FILES" | xargs $(YAPF) --parallel --in-place