-
Notifications
You must be signed in to change notification settings - Fork 117
134 lines (132 loc) · 4.81 KB
/
unit-test.yml
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
name: Unit tests
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
unit-test:
name: Unit tests for ${{ matrix.os }}, PyTorch ${{ matrix.vers.pt_ver }}
runs-on: ${{ matrix.os }}
strategy:
fail-fast: false
matrix:
os: ["ubuntu-latest", "macos-13", "windows-latest"]
vers: [ {pt_ver: "1.6.0", tv_ver: "0.7.0"}, {pt_ver: "latest", tv_ver: "latest"} ]
include:
- os: macos-latest
vers:
pt_ver: latest
tv_ver: latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v4
- uses: conda-incubator/setup-miniconda@v3
with:
auto-update-conda: true
python-version: 3.8
- name: Install PyTorch
env:
PYTORCH_VER: ${{ matrix.vers.pt_ver }}
TORCHVISION_VER: ${{ matrix.vers.tv_ver }}
run: |
if [ "$RUNNER_OS" == "macOS" ]; then
if [[ "$TORCHVISION_VER" == "latest" && "$PYTORCH_VER" == "latest" ]]; then
conda install pytorch::pytorch torchvision -c pytorch
elif [[ "$TORCHVISION_VER" == "0.9."* || "$TORCHVISION_VER" == "0.10."* ]]; then
conda install pytorch=$PYTORCH_VER torchvision=$TORCHVISION_VER pillow=6 -c pytorch
else
conda install pytorch=$PYTORCH_VER torchvision=$TORCHVISION_VER -c pytorch
fi
elif [ "$RUNNER_OS" == "Windows" ]; then
if [[ "$TORCHVISION_VER" == "latest" && "$PYTORCH_VER" == "latest" ]]; then
conda install pytorch torchvision cpuonly pillow=6 -c pytorch
elif [[ "$TORCHVISION_VER" == "0.9."* || "$TORCHVISION_VER" == "0.10."* ]]; then
conda install pillow=6 -c conda-forge
conda install pytorch=$PYTORCH_VER torchvision=$TORCHVISION_VER cpuonly -c pytorch
else
conda install pytorch=$PYTORCH_VER torchvision=$TORCHVISION_VER cpuonly pillow=6 -c pytorch
fi
else
if [[ "$TORCHVISION_VER" == "latest" && "$PYTORCH_VER" == "latest" ]]; then
conda install pytorch torchvision cpuonly -c pytorch
else
conda install pytorch=$PYTORCH_VER torchvision=$TORCHVISION_VER cpuonly -c pytorch
fi
fi
- name: Install TinyNeuralNetwork
run: pip install .
- name: Install test dependencies
env:
PYTORCH_VER: ${{ matrix.vers.pt_ver }}
TORCHVISION_VER: ${{ matrix.vers.tv_ver }}
run: |
if [[ "$RUNNER_OS" == "Linux" && "$TORCHVISION_VER" == "latest" && "$PYTORCH_VER" == "latest" ]]; then
pip install black 'ruff<0.0.234' 'tensorflow<2.12' scipy interval
else
pip install black 'ruff<0.0.234' tensorflow scipy interval
fi
- name: Lint checks
run: python -m ruff .
- name: Style checks
run: python -m black .
- name: Run unit tests
run: |
cd tests
python import_test.py -v
python converter_op_test.py -v
python converter_optimizer_test.py -v
python quantizer_test.py -v
python modifier_prune_test.py -v
python modifier_test.py -v
python cross_layer_equalization_test.py -v
- name: Run integration tests
run: |
source activate.sh
cd tests
rm -rf out || true
python converter_test.py -v -k mobilenet
if [ "$RUNNER_OS" != "Windows" ]; then
rm -rf out || true
python converter_qat_test.py -v -k mobilenet
fi
rm -rf out || true
python tracer_test.py -v -k mobilenet
misc-check:
name: Misc checks
runs-on: ubuntu-latest
defaults:
run:
shell: bash -l {0}
steps:
- uses: actions/checkout@v2
- uses: conda-incubator/setup-miniconda@v2
with:
auto-update-conda: true
python-version: 3.8
- name: Install PyTorch
run: conda install pytorch torchvision cpuonly -c pytorch
- name: Install TinyNeuralNetwork
run: pip install .
- name: Check op matrix
run: |
python scripts/gen_op_docs.py
if [[ $(git diff --stat) != '' ]]; then
echo "OP matrix is not updated. Please run python scripts/gen_op_docs.py and update your commit"
echo "Differences:"
git --no-pager diff
exit 1
fi
- name: Check quantization support
run: |
python scripts/gen_quantized_docs.py
if [[ $(git diff --stat) != '' ]]; then
echo "Quantization support doc is not updated. Please run python scripts/gen_quantized_docs.py and update your commit"
echo "Differences:"
git --no-pager diff
exit 1
fi