-
Notifications
You must be signed in to change notification settings - Fork 12
255 lines (216 loc) · 9.16 KB
/
mlir-tensorrt-ci.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
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
name: MLIR-TensorRT CI
on:
pull_request:
branches:
- main
types: [synchronize, opened, reopened, ready_for_review]
paths: ["mlir-tensorrt/**"]
env:
DEFAULT_IMAGE: ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt:cuda12.5-ubuntu-llvm17
REGISTRY: ghcr.io
jobs:
mlir-tensorrt-tests:
if: github.event.pull_request.draft == false
# `ubuntu-latest` is a CPU runner.
# If selected, tests requiring GPU are not run.
runs-on: ubuntu-latest
steps:
# Free some disk space, otherwise we get OOM error.
- name: Free disk space
run: |
sudo rm -rf \
/usr/share/dotnet "$AGENT_TOOLSDIRECTORY" /usr/local/lib/android /opt/ghc \
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \
/usr/lib/jvm
sudo apt-get purge microsoft-edge-stable || true
sudo apt-get purge google-cloud-cli || true
sudo apt-get purge dotnet-sdk-* || true
sudo apt-get purge google-chrome-stable || true
sudo apt-get autoremove -y
sudo apt-get autoclean -y
# Value of `github.workspace` is /home/runner/work/{repo_name}/{repo-name}
# i.e. /home/runner/work/TensorRT-Incubator/TensorRT-Incubator in our case.
# After this action, repo is cloned inside above path.
- uses: actions/checkout@v4
with:
fetch-depth: 5
- name: Validate commit message
env:
PR_HEAD_COMMIT_SHA: ${{ github.event.pull_request.head.sha }}
run: |
cat > commit_message_checker.py <<EOF
#!/usr/bin/python3
import re
import sys
import subprocess
git_cmd = f"git show -s --format=%B {sys.argv[1]}"
try:
commit_message_cmd = subprocess.run(git_cmd.split(' '), capture_output=True, text=True, check=True)
commit_message = commit_message_cmd.stdout.strip()
except subprocess.CalledProcessError as e:
print(f"Failed to get PR HEAD commit message with error: {e.stderr.strip()}")
match = re.search(r"^(\[bot\].+|NFC: .+|(.+\n\n+.+\n+.+))$", commit_message, re.DOTALL)
if match:
print("Commit message is in canonical form :)")
sys.exit(0)
print("Commit message is not in the canonical form!")
print(commit_message)
print("")
print("Expected format is, ")
print("<title>")
print("<body>")
print("NOTE: Body should start on new line. '2 spaces + enter' for new line!")
print("NOTE: Body should be at least two lines.")
sys.exit(1)
EOF
python3 commit_message_checker.py ${PR_HEAD_COMMIT_SHA}
# Run initial format check
- name: Run python format and clang check
uses: addnab/docker-run-action@v3
with:
image: ${{ env.DEFAULT_IMAGE }}
options: -v ${{ github.workspace }}:/tensorrt-incubator
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
# This step does two things
# 1. Check if Python files follow black format
# 2. Check if C++ files follow clang format
# NOTE: We are placed at the root directory ('/') inside the container.
run: |
cd tensorrt-incubator
git config --global --add safe.directory /tensorrt-incubator
cat > run_format_check.sh <<EOF
#!/bin/bash
set -e
python3 -m black --check --exclude='.*\.pyi' mlir-tensorrt/test/
python3 -m black --check --exclude='.*\.pyi' mlir-tensorrt/python/
git clang-format HEAD~1 --diff
EOF
bash run_format_check.sh
# Create cache folders
- name: Create cache folder
run: |
mkdir -p ${{ github.workspace }}/ccache
mkdir -p ${{ github.workspace }}/.ccache.cpm
# Create cache action
- name: Create cache action
id: core-build-cache
uses: actions/cache@v4
with:
key: ${{ runner.os }}-mlir-tensorrt-core-build
path: |
${{ github.workspace }}/ccache
${{ github.workspace }}/.ccache.cpm
# Run LIT tests with TensorRT 10
- name: Run MLIR-TensorRT lit tests with TensorRT 10
uses: addnab/docker-run-action@v3
with:
image: ${{ env.DEFAULT_IMAGE }}
options: -v ${{ github.workspace }}/mlir-tensorrt:/mlir-tensorrt -v ${{ github.workspace }}/ccache:/ccache -v ${{ github.workspace }}/.ccache.cpm:/.ccache.cpm
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
run: |
export CCACHE_BASEDIR="$PWD"
export CCACHE_DIR="$PWD/ccache"
export CCACHE_COMPILERCHECK=content
export CCACHE_MAXSIZE=10G
ccache --zero-stats || true
ccache --show-stats || true
cd mlir-tensorrt
cat > build_and_test.sh <<EOF
#!/bin/bash
set -e
python3 -m pip install -r python/requirements-dev.txt
cmake -B ./build -S . -G Ninja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DMLIR_TRT_PACKAGE_CACHE_DIR=${PWD}/.cache.cpm \
-DMLIR_TRT_ENABLE_ASSERTIONS=ON \
-DMLIR_TRT_DOWNLOAD_TENSORRT_VERSION=10.2 \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DMLIR_TRT_USE_LINKER=lld \
-DMLIR_EXECUTOR_ENABLE_GPU_INTEGRATION_TESTS=OFF
ninja -C build all
ninja -C build check-mlir-executor
ninja -C build check-mlir-tensorrt-dialect
ninja -C build check-mlir-tensorrt
cd ..
ccache --show-stats || true
EOF
bash build_and_test.sh
# Run LIT tests with TensorRT 10 & ASAN
- name: Run MLIR-TensorRT lit tests with TensorRT 10, ASAN enabled
uses: addnab/docker-run-action@v3
with:
image: ${{ env.DEFAULT_IMAGE }}
options: -v ${{ github.workspace }}/mlir-tensorrt:/mlir-tensorrt -v ${{ github.workspace }}/ccache:/ccache -v ${{ github.workspace }}/.ccache.cpm:/.ccache.cpm
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
run: |
export CCACHE_BASEDIR="$PWD"
export CCACHE_DIR="$PWD/ccache"
export CCACHE_COMPILERCHECK=content
export CCACHE_MAXSIZE=10G
ccache --zero-stats || true
ccache --show-stats || true
cd mlir-tensorrt
cat > build_and_test.sh <<EOF
#!/bin/bash
set -e
python3 -m pip install -r python/requirements-dev.txt
cmake -B ./build -S . -G Ninja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DMLIR_TRT_PACKAGE_CACHE_DIR=${PWD}/.cache.cpm \
-DMLIR_TRT_ENABLE_ASSERTIONS=ON \
-DMLIR_TRT_DOWNLOAD_TENSORRT_VERSION=10.2 \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DMLIR_TRT_USE_LINKER=lld \
-DMLIR_EXECUTOR_ENABLE_GPU_INTEGRATION_TESTS=OFF \
-DENABLE_ASAN=ON
ninja -C build all
ninja -C build check-mlir-executor
ninja -C build check-mlir-tensorrt-dialect
ninja -C build check-mlir-tensorrt
cd ..
ccache --show-stats || true
EOF
bash build_and_test.sh
# Run LIT tests with TensorRT 9
- name: Run MLIR-TensorRT lit tests with TensorRT 9
uses: addnab/docker-run-action@v3
with:
image: ${{ env.DEFAULT_IMAGE }}
options: -v ${{ github.workspace }}/mlir-tensorrt:/mlir-tensorrt -v ${{ github.workspace }}/ccache:/ccache -v ${{ github.workspace }}/.ccache.cpm:/.ccache.cpm
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
run: |
export CCACHE_BASEDIR="$PWD"
export CCACHE_DIR="$PWD/ccache"
export CCACHE_COMPILERCHECK=content
export CCACHE_MAXSIZE=10G
ccache --zero-stats || true
ccache --show-stats || true
cd mlir-tensorrt
cat > build_and_test.sh <<EOF
#!/bin/bash
set -e
python3 -m pip install -r python/requirements-dev.txt
cmake -B ./build -S . -G Ninja \
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
-DMLIR_TRT_PACKAGE_CACHE_DIR=${PWD}/.cache.cpm \
-DMLIR_TRT_ENABLE_ASSERTIONS=ON \
-DMLIR_TRT_DOWNLOAD_TENSORRT_VERSION=9.2.0.5 \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DMLIR_TRT_USE_LINKER=lld \
-DMLIR_EXECUTOR_ENABLE_GPU_INTEGRATION_TESTS=OFF
ninja -C build all
ninja -C build check-mlir-executor
ninja -C build check-mlir-tensorrt-dialect
ninja -C build check-mlir-tensorrt
cd ..
ccache --show-stats || true
EOF
bash build_and_test.sh