-
Notifications
You must be signed in to change notification settings - Fork 2
321 lines (306 loc) · 10.2 KB
/
Copy pathci.yml
File metadata and controls
321 lines (306 loc) · 10.2 KB
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
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
name: CI
on:
push:
pull_request:
schedule:
- cron: '0 8 * * *'
workflow_dispatch:
jobs:
clang-format:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: DoozyX/clang-format-lint-action@v0.15
with:
source: './app ./include ./src ./test'
build-linux:
strategy:
matrix:
include:
- build_type: DEBUG
- build_type: RELEASE
stats: false
- build_type: RELEASE
stats: true
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Set binary paths
id: set_binaries
run: |
echo "ACC_BINARY=build/bin/ACC" >> $GITHUB_OUTPUT
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ccache-${{ github.job }}-${{ matrix.build_type }}
max-size: 2G
- name: Build
run: |
cmake -S . -B build -G Ninja \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DOPENCV_PATH=build/3rdparty/opencv_build \
${{ matrix.stats && '-DENABLE_STATISTIC_TENSORS=ON' || '' }} \
${{ matrix.stats && '-DENABLE_STATISTIC_TIME=ON' || '' }} \
${{ matrix.stats && '-DENABLE_STATISTIC_WEIGHTS=ON' || '' }}
cmake --build build --parallel
env:
CTEST_OUTPUT_ON_FAILURE: 1
- name: Prepare ALL libs
run: |
mkdir -p build/bin/all_libs
cp -a build/3rdparty/opencv_build/lib/* build/bin/all_libs/ 2>/dev/null || true
ldd build/bin/ACC | grep "=> /" | awk '{print $3}' | xargs -I {} cp {} build/bin/all_libs/ 2>/dev/null || true
- name: Upload artifacts
uses: actions/upload-artifact@v4
with:
name: mnist-${{ matrix.build_type }}${{ matrix.stats && '-stats' || '' }}
path: |
${{ steps.set_binaries.outputs.ACC_BINARY }}
build/bin/all_libs/*
build/bin/opencv_libs/*
build/setenv.sh
- name: Test
run: cmake --build build -t test
env:
CTEST_OUTPUT_ON_FAILURE: 1
- name: Test (valgrind)
run: |
sudo apt-get update
sudo apt-get install -y valgrind
valgrind cmake --build build -t test
env:
CTEST_OUTPUT_ON_FAILURE: 1
build-linux-clang:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install prerequisites
run: |
sudo apt install clang libomp-dev
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ccache-${{ github.job }}
- name: Build
run: |
cmake -S . -B build -G Ninja \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER=clang \
-DCMAKE_CXX_COMPILER=clang++
cmake --build build --parallel
- name: Test
run: cmake --build build -t test
env:
CTEST_OUTPUT_ON_FAILURE: 1
- name: Test (valgrind)
run: |
sudo apt-get update
sudo apt-get install -y valgrind
valgrind cmake --build build -t test
env:
CTEST_OUTPUT_ON_FAILURE: 1
build-macos:
runs-on: macos-15
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install prerequisites
run: |
brew install libomp ninja
brew link libomp --overwrite --force
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ccache-${{ github.job }}
- name: Build
run: |
OPENMP_PATH=$(brew --prefix libomp)
echo "OpenMP path: $OPENMP_PATH"
cmake -S . -B build -G Ninja \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_PREFIX_PATH=$OPENMP_PATH \
-DCMAKE_INCLUDE_PATH=$OPENMP_PATH/include \
-DCMAKE_LIBRARY_PATH=$OPENMP_PATH/lib \
-DOpenMP_C_FLAGS="-Xclang -fopenmp -I$OPENMP_PATH/include" \
-DOpenMP_CXX_FLAGS="-Xclang -fopenmp -I$OPENMP_PATH/include" \
-DOpenMP_C_LIB_NAMES="omp" \
-DOpenMP_CXX_LIB_NAMES="omp" \
-DOpenMP_omp_LIBRARY="$OPENMP_PATH/lib/libomp.dylib" \
-DCMAKE_EXE_LINKER_FLAGS="-L$OPENMP_PATH/lib -lomp" \
-DCMAKE_SHARED_LINKER_FLAGS="-L$OPENMP_PATH/lib -lomp"
cmake --build build --parallel
env:
LDFLAGS: "-L$(brew --prefix libomp)/lib -lomp"
CPPFLAGS: "-I$(brew --prefix libomp)/include"
- name: Test
run: cmake --build build -t test
env:
CTEST_OUTPUT_ON_FAILURE: 1
build-windows:
runs-on: windows-2025
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Add msbuild to PATH
uses: microsoft/setup-msbuild@v2
with:
vs-version: 'latest'
- name: Setup ccache
uses: Chocobo1/setup-ccache-action@v1
with:
windows_compile_environment: msvc
- name: Setup ninja
uses: seanmiddleditch/gha-setup-ninja@v6
- name: Setup MSVC for Ninja again
uses: ilammy/msvc-dev-cmd@v1
- name: Build
run: |
cmake -S . -B build -G Ninja -DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache -DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel --config Release
- name: Test
run: |
cd build
ctest --output-on-failure
build-linux-arm64:
runs-on: ubuntu-24.04-arm
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install prerequisites
run: sudo apt-get update && sudo apt-get install -y libomp-dev build-essential cmake
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ccache-${{ github.job }}
- name: Build and Test
run: |
cmake -S . -B build -G Ninja \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_BUILD_TYPE=Release
cmake --build build --parallel
cmake --build build -t test
env:
CTEST_OUTPUT_ON_FAILURE: 1
codecov:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: true
- name: Install dependencies
run: sudo apt-get update && sudo apt-get install -y gcovr
- name: Setup ccache
uses: hendrikmuhs/ccache-action@v1.2
with:
key: ccache-${{ github.job }}-${{ matrix.build_type }}
max-size: 2G
- name: Build
run: |
cmake -S . -B build -G Ninja \
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_FLAGS="--coverage" \
-DCMAKE_CXX_FLAGS="--coverage" \
-DCMAKE_BUILD_TYPE=RelWithDebInfo
cmake --build build --parallel
- name: Test
run: cmake --build build -t test
env:
CTEST_OUTPUT_ON_FAILURE: 1
- name: Generate Coverage Data
run: gcovr -r . --xml -o coverage.xml --gcov-ignore-parse-errors
- name: Upload coverage reports to Codecov
uses: codecov/codecov-action@v4.0.1
with:
token: ${{ secrets.CODECOV_TOKEN }}
slug: embedded-dev-research/ITLabAI
evaluate-model:
runs-on: ubuntu-latest
needs: [build-linux]
permissions:
contents: write
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Download binary and libs
uses: actions/download-artifact@v4
with:
name: mnist-RELEASE
path: build/
- name: Set binary path
id: set_eval_binary
run: |
echo "EVAL_BINARY=build/bin/ACC" >> $GITHUB_OUTPUT
- name: Install system dependencies
run: |
sudo apt-get update
sudo apt-get install -y libgtk-3-0 libtbb12 libjpeg-dev libpng-dev libtiff-dev libopenjp2-7 libdnnl3
sudo ldconfig
- name: Generate model JSON
run: |
cd docs && mkdir -p jsons
cd ..
cd app/Converters
pip install -r requirements.txt
python parser.py
cd ../..
- name: Cache MNIST test dataset
id: cache-mnist
uses: actions/cache@v4
with:
path: docs/mnist/mnist/test
key: mnist-dataset-e2d09c892023700f68bfa9f30ac91a4dffaa23b151deeaca627101b3d73ef83d
- name: Download MNIST test dataset
if: steps.cache-mnist.outputs.cache-hit != 'true'
run: |
mkdir -p docs/mnist/mnist/test
wget -q https://github.com/DeepTrackAI/MNIST_dataset/archive/main.zip -O main.zip
unzip -q main.zip
cp MNIST_dataset-main/mnist/test/*.png docs/mnist/mnist/test/
rm -rf main.zip MNIST_dataset-main
- name: Prepare environment
run: |
chmod +x "${{ steps.set_eval_binary.outputs.EVAL_BINARY }}"
export LD_LIBRARY_PATH=$PWD/build/bin/all_libs:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
- name: Run evaluation
run: |
export LD_LIBRARY_PATH=$PWD/build/bin/all_libs:/usr/lib/x86_64-linux-gnu:$LD_LIBRARY_PATH
"${{ steps.set_eval_binary.outputs.EVAL_BINARY }}" --model alexnet_mnist > accuracy.txt 2>&1
if [ $? -ne 0 ]; then
exit 1
fi
- name: Extract accuracy value
run: |
ACCURACY=$(grep -oE '[0-9]+\.?[0-9]*%' accuracy.txt | head -1 || echo "0%")
echo "$ACCURACY" > accuracy_value.txt
- name: Update README (master only)
if: github.ref == 'refs/heads/master'
run: |
ACCURACY=$(cat accuracy_value.txt | sed 's/%//g')
DATE=$(date '+%Y-%m-%d')
sed -i "s/<!--ACCURACY_PLACEHOLDER-->.*<!--END_ACCURACY-->/<!--ACCURACY_PLACEHOLDER-->Accuracy: ${ACCURACY}% (updated: ${DATE})<!--END_ACCURACY-->/" README.md
- name: Commit and push changes (master only)
if: github.ref == 'refs/heads/master'
run: |
git config --global user.name "GitHub Actions"
git config --global user.email "actions@github.com"
git add README.md
if git diff-index --quiet HEAD --; then
echo "No changes to commit"
else
git commit -m "[CI] Update accuracy: $(cat accuracy_value.txt)"
git push origin master
fi