Skip to content

Commit 1176dbd

Browse files
committed
Merge remote-tracking branch 'origin/main' into sam2
2 parents 23851b8 + 87733ec commit 1176dbd

File tree

29 files changed

+855
-435
lines changed

29 files changed

+855
-435
lines changed

.github/workflows/mlir-tensorrt-ci.yml

Lines changed: 188 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,18 @@ on:
66
- main
77
types: [synchronize, opened, reopened, ready_for_review]
88
paths: ["mlir-tensorrt/**"]
9+
push:
10+
branches:
11+
- main
12+
paths: ["mlir-tensorrt/**"]
913

1014
env:
1115
DEFAULT_IMAGE: ghcr.io/nvidia/tensorrt-incubator/mlir-tensorrt:cuda12.5-ubuntu-llvm17
1216
REGISTRY: ghcr.io
1317

1418
jobs:
15-
mlir-tensorrt-tests:
16-
if: github.event.pull_request.draft == false
19+
mlir-tensorrt-test-pr:
20+
if: github.event_name == 'pull_request' && github.event.pull_request.draft == false
1721
# `ubuntu-latest` is a CPU runner.
1822
# If selected, tests requiring GPU are not run.
1923
runs-on: ubuntu-latest
@@ -128,9 +132,183 @@ jobs:
128132
username: ${{ github.actor }}
129133
password: ${{ secrets.GITHUB_TOKEN }}
130134
run: |
131-
export CCACHE_BASEDIR="$PWD"
132-
export CCACHE_DIR="$PWD/ccache"
133-
export CCACHE_COMPILERCHECK=content
135+
export CCACHE_DIR="/ccache"
136+
export CCACHE_MAXSIZE=10G
137+
ccache --zero-stats || true
138+
ccache --show-stats || true
139+
140+
cd mlir-tensorrt
141+
cat > build_and_test.sh <<EOF
142+
#!/bin/bash
143+
set -e
144+
145+
python3 -m pip install -r python/requirements-dev.txt
146+
147+
cmake -B ./build -S . -G Ninja \
148+
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
149+
-DMLIR_TRT_PACKAGE_CACHE_DIR=/.cache.cpm \
150+
-DMLIR_TRT_ENABLE_ASSERTIONS=ON \
151+
-DMLIR_TRT_DOWNLOAD_TENSORRT_VERSION=10.2 \
152+
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
153+
-DMLIR_TRT_USE_LINKER=lld \
154+
-DMLIR_EXECUTOR_ENABLE_GPU_INTEGRATION_TESTS=OFF
155+
156+
ninja -C build all
157+
158+
ninja -C build check-mlir-executor
159+
ninja -C build check-mlir-tensorrt-dialect
160+
ninja -C build check-mlir-tensorrt
161+
162+
cd ..
163+
ccache --show-stats || true
164+
EOF
165+
166+
bash build_and_test.sh
167+
168+
# Run LIT tests with TensorRT 10 & ASAN
169+
- name: Run MLIR-TensorRT lit tests with TensorRT 10, ASAN enabled
170+
uses: addnab/docker-run-action@v3
171+
with:
172+
image: ${{ env.DEFAULT_IMAGE }}
173+
options: -v ${{ github.workspace }}/mlir-tensorrt:/mlir-tensorrt -v ${{ github.workspace }}/ccache:/ccache -v ${{ github.workspace }}/.ccache.cpm:/.ccache.cpm
174+
registry: ${{ env.REGISTRY }}
175+
username: ${{ github.actor }}
176+
password: ${{ secrets.GITHUB_TOKEN }}
177+
run: |
178+
export CCACHE_DIR="/ccache"
179+
export CCACHE_MAXSIZE=10G
180+
ccache --zero-stats || true
181+
ccache --show-stats || true
182+
183+
cd mlir-tensorrt
184+
cat > build_and_test.sh <<EOF
185+
#!/bin/bash
186+
set -e
187+
188+
python3 -m pip install -r python/requirements-dev.txt
189+
190+
cmake -B ./build -S . -G Ninja \
191+
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
192+
-DMLIR_TRT_PACKAGE_CACHE_DIR=/.cache.cpm \
193+
-DMLIR_TRT_ENABLE_ASSERTIONS=ON \
194+
-DMLIR_TRT_DOWNLOAD_TENSORRT_VERSION=10.2 \
195+
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
196+
-DMLIR_TRT_USE_LINKER=lld \
197+
-DMLIR_EXECUTOR_ENABLE_GPU_INTEGRATION_TESTS=OFF \
198+
-DENABLE_ASAN=ON
199+
200+
ninja -C build all
201+
202+
ninja -C build check-mlir-executor
203+
ninja -C build check-mlir-tensorrt-dialect
204+
ninja -C build check-mlir-tensorrt
205+
206+
cd ..
207+
ccache --show-stats || true
208+
EOF
209+
210+
bash build_and_test.sh
211+
212+
# Run LIT tests with TensorRT 9
213+
- name: Run MLIR-TensorRT lit tests with TensorRT 9
214+
uses: addnab/docker-run-action@v3
215+
with:
216+
image: ${{ env.DEFAULT_IMAGE }}
217+
options: -v ${{ github.workspace }}/mlir-tensorrt:/mlir-tensorrt -v ${{ github.workspace }}/ccache:/ccache -v ${{ github.workspace }}/.ccache.cpm:/.ccache.cpm
218+
registry: ${{ env.REGISTRY }}
219+
username: ${{ github.actor }}
220+
password: ${{ secrets.GITHUB_TOKEN }}
221+
run: |
222+
export CCACHE_DIR="/ccache"
223+
export CCACHE_MAXSIZE=10G
224+
ccache --zero-stats || true
225+
ccache --show-stats || true
226+
227+
cd mlir-tensorrt
228+
cat > build_and_test.sh <<EOF
229+
#!/bin/bash
230+
set -e
231+
232+
python3 -m pip install -r python/requirements-dev.txt
233+
234+
cmake -B ./build -S . -G Ninja \
235+
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
236+
-DMLIR_TRT_PACKAGE_CACHE_DIR=/.cache.cpm \
237+
-DMLIR_TRT_ENABLE_ASSERTIONS=ON \
238+
-DMLIR_TRT_DOWNLOAD_TENSORRT_VERSION=9.2.0.5 \
239+
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
240+
-DMLIR_TRT_USE_LINKER=lld \
241+
-DMLIR_EXECUTOR_ENABLE_GPU_INTEGRATION_TESTS=OFF
242+
243+
ninja -C build all
244+
245+
ninja -C build check-mlir-executor
246+
ninja -C build check-mlir-tensorrt-dialect
247+
ninja -C build check-mlir-tensorrt
248+
249+
cd ..
250+
ccache --show-stats || true
251+
EOF
252+
253+
bash build_and_test.sh
254+
255+
mlir-tensorrt-test-main:
256+
if: github.event_name == 'push'
257+
# `ubuntu-latest` is a CPU runner.
258+
# If selected, tests requiring GPU are not run.
259+
runs-on: ubuntu-latest
260+
261+
steps:
262+
# Free some disk space, otherwise we get OOM error.
263+
- name: Free disk space
264+
run: |
265+
sudo rm -rf \
266+
/usr/share/dotnet "$AGENT_TOOLSDIRECTORY" /usr/local/lib/android /opt/ghc \
267+
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \
268+
/usr/lib/jvm
269+
270+
sudo apt-get purge microsoft-edge-stable || true
271+
sudo apt-get purge google-cloud-cli || true
272+
sudo apt-get purge dotnet-sdk-* || true
273+
sudo apt-get purge google-chrome-stable || true
274+
275+
sudo apt-get autoremove -y
276+
sudo apt-get autoclean -y
277+
278+
# Value of `github.workspace` is /home/runner/work/{repo_name}/{repo-name}
279+
# i.e. /home/runner/work/TensorRT-Incubator/TensorRT-Incubator in our case.
280+
# After this action, repo is cloned inside above path.
281+
- uses: actions/checkout@v4
282+
with:
283+
fetch-depth: 5
284+
285+
# Create cache folders
286+
- name: Create cache folder
287+
run: |
288+
mkdir -p ${{ github.workspace }}/ccache
289+
mkdir -p ${{ github.workspace }}/.ccache.cpm
290+
291+
# Create cache action
292+
- name: Create cache action
293+
id: core-build-cache
294+
uses: actions/cache@v4
295+
with:
296+
key: ${{ runner.os }}-mlir-tensorrt-core-build
297+
path: |
298+
${{ github.workspace }}/ccache
299+
${{ github.workspace }}/.ccache.cpm
300+
301+
# Run LIT tests with TensorRT 10
302+
- name: Run MLIR-TensorRT lit tests with TensorRT 10
303+
uses: addnab/docker-run-action@v3
304+
with:
305+
image: ${{ env.DEFAULT_IMAGE }}
306+
options: -v ${{ github.workspace }}/mlir-tensorrt:/mlir-tensorrt -v ${{ github.workspace }}/ccache:/ccache -v ${{ github.workspace }}/.ccache.cpm:/.ccache.cpm
307+
registry: ${{ env.REGISTRY }}
308+
username: ${{ github.actor }}
309+
password: ${{ secrets.GITHUB_TOKEN }}
310+
run: |
311+
export CCACHE_DIR="/ccache"
134312
export CCACHE_MAXSIZE=10G
135313
ccache --zero-stats || true
136314
ccache --show-stats || true
@@ -144,7 +322,7 @@ jobs:
144322
145323
cmake -B ./build -S . -G Ninja \
146324
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
147-
-DMLIR_TRT_PACKAGE_CACHE_DIR=${PWD}/.cache.cpm \
325+
-DMLIR_TRT_PACKAGE_CACHE_DIR=/.cache.cpm \
148326
-DMLIR_TRT_ENABLE_ASSERTIONS=ON \
149327
-DMLIR_TRT_DOWNLOAD_TENSORRT_VERSION=10.2 \
150328
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
@@ -173,9 +351,7 @@ jobs:
173351
username: ${{ github.actor }}
174352
password: ${{ secrets.GITHUB_TOKEN }}
175353
run: |
176-
export CCACHE_BASEDIR="$PWD"
177-
export CCACHE_DIR="$PWD/ccache"
178-
export CCACHE_COMPILERCHECK=content
354+
export CCACHE_DIR="/ccache"
179355
export CCACHE_MAXSIZE=10G
180356
ccache --zero-stats || true
181357
ccache --show-stats || true
@@ -189,7 +365,7 @@ jobs:
189365
190366
cmake -B ./build -S . -G Ninja \
191367
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
192-
-DMLIR_TRT_PACKAGE_CACHE_DIR=${PWD}/.cache.cpm \
368+
-DMLIR_TRT_PACKAGE_CACHE_DIR=/.cache.cpm \
193369
-DMLIR_TRT_ENABLE_ASSERTIONS=ON \
194370
-DMLIR_TRT_DOWNLOAD_TENSORRT_VERSION=10.2 \
195371
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
@@ -219,9 +395,7 @@ jobs:
219395
username: ${{ github.actor }}
220396
password: ${{ secrets.GITHUB_TOKEN }}
221397
run: |
222-
export CCACHE_BASEDIR="$PWD"
223-
export CCACHE_DIR="$PWD/ccache"
224-
export CCACHE_COMPILERCHECK=content
398+
export CCACHE_DIR="/ccache"
225399
export CCACHE_MAXSIZE=10G
226400
ccache --zero-stats || true
227401
ccache --show-stats || true
@@ -235,7 +409,7 @@ jobs:
235409
236410
cmake -B ./build -S . -G Ninja \
237411
-DCMAKE_BUILD_TYPE=RelWithDebInfo \
238-
-DMLIR_TRT_PACKAGE_CACHE_DIR=${PWD}/.cache.cpm \
412+
-DMLIR_TRT_PACKAGE_CACHE_DIR=/.cache.cpm \
239413
-DMLIR_TRT_ENABLE_ASSERTIONS=ON \
240414
-DMLIR_TRT_DOWNLOAD_TENSORRT_VERSION=9.2.0.5 \
241415
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \

mlir-tensorrt/compiler/include/mlir-tensorrt-c/Compiler/Compiler.h

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -108,38 +108,6 @@ MLIR_CAPI_EXPORTED MTRT_Status mtrtCompilerStableHLOToExecutable(
108108
MTRT_CompilerClient client, MlirOperation module,
109109
MTRT_StableHLOToExecutableOptions options, MTRT_Executable *result);
110110

111-
//===----------------------------------------------------------------------===//
112-
// MTRT_StableHLOProgramSignatureRefinementOptions
113-
//===----------------------------------------------------------------------===//
114-
115-
/// Options for compiling StableHLO MLIR to an Executable.
116-
typedef struct MTRT_StableHLOProgramSignatureRefinementOptions {
117-
void *ptr;
118-
} MTRT_StableHLOProgramSignatureRefinementOptions;
119-
120-
MLIR_CAPI_EXPORTED MTRT_Status
121-
mtrtStableHloProgramSignatureRefinementOptionsCreate(
122-
MTRT_StringView funcName,
123-
MTRT_StableHLOProgramSignatureRefinementOptions *options);
124-
125-
MLIR_CAPI_EXPORTED MTRT_Status
126-
mtrtStableHloProgramSignatureRefinementOptionsDestroy(
127-
MTRT_StableHLOProgramSignatureRefinementOptions options);
128-
129-
static inline bool mtrtStableHloProgramSignatureRefinementOptionsIsNull(
130-
MTRT_StableHLOProgramSignatureRefinementOptions options) {
131-
return !options.ptr;
132-
}
133-
134-
//===----------------------------------------------------------------------===//
135-
// Main StableHLO Program Signature Refinement API Functions
136-
//===----------------------------------------------------------------------===//
137-
138-
/// Compiler StableHLO to Executable.
139-
MLIR_CAPI_EXPORTED MTRT_Status mtrtGetStableHloProgramRefinedSignature(
140-
MTRT_CompilerClient client, MlirOperation module,
141-
MTRT_StableHLOProgramSignatureRefinementOptions options, MlirType *result);
142-
143111
#ifdef __cplusplus
144112
}
145113
#endif

mlir-tensorrt/compiler/include/mlir-tensorrt/Compiler/StableHloToExecutable.h

Lines changed: 0 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -44,41 +44,6 @@
4444

4545
namespace mlirtrt::compiler {
4646

47-
//===----------------------------------------------------------------------===//
48-
// StableHLOProgramSignatureRefinementOptions
49-
//===----------------------------------------------------------------------===//
50-
51-
struct StableHLOProgramSignatureRefinementOptions
52-
: public mlir::OptionsContext {
53-
/// Creates default compilation options.
54-
StableHLOProgramSignatureRefinementOptions() {
55-
this->addOption("func-name", funcName, llvm::cl::init("main"));
56-
debugOptions.addToOptions(*this);
57-
}
58-
59-
/// Set the entrypoint function name.
60-
StableHLOProgramSignatureRefinementOptions &
61-
setFuncName(const std::string &name) {
62-
funcName = name;
63-
return *this;
64-
}
65-
66-
std::string funcName = "main";
67-
68-
DebugOptions debugOptions;
69-
};
70-
71-
//===----------------------------------------------------------------------===//
72-
// StableHLO Signature Refinement Entrypoint
73-
//===----------------------------------------------------------------------===//
74-
75-
/// Attempt to refine the function signature of a StableHLO program through
76-
/// canonicalization and constant folding. Returns the refined signature of the
77-
/// specified function of the module.
78-
mlirtrt::StatusOr<mlir::FunctionType> getStableHLOProgramRefinedSignature(
79-
CompilerClient &client, mlir::ModuleOp module,
80-
const StableHLOProgramSignatureRefinementOptions &options);
81-
8247
//===----------------------------------------------------------------------===//
8348
// StableHLOToExecutableOptions
8449
//===----------------------------------------------------------------------===//

mlir-tensorrt/compiler/lib/CAPI/Compiler/Compiler.cpp

Lines changed: 0 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ using namespace mlir;
4444
DEFINE_C_API_PTR_METHODS(MTRT_CompilerClient, CompilerClient)
4545
DEFINE_C_API_PTR_METHODS(MTRT_StableHLOToExecutableOptions,
4646
StableHLOToExecutableOptions)
47-
DEFINE_C_API_PTR_METHODS(MTRT_StableHLOProgramSignatureRefinementOptions,
48-
StableHLOProgramSignatureRefinementOptions)
4947
#if defined(__GNUC__) || defined(__clang__)
5048
#pragma GCC diagnostic pop
5149
#endif
@@ -255,43 +253,3 @@ MTRT_Status mtrtCompilerStableHLOToExecutable(
255253

256254
return mtrtStatusGetOk();
257255
}
258-
259-
//===----------------------------------------------------------------------===//
260-
// Main StableHLO Program Signature Refinement Functions
261-
//===----------------------------------------------------------------------===//
262-
263-
MTRT_Status mtrtStableHloProgramSignatureRefinementOptionsCreate(
264-
MTRT_StringView funcName,
265-
MTRT_StableHLOProgramSignatureRefinementOptions *options) {
266-
auto result = std::make_unique<StableHLOProgramSignatureRefinementOptions>();
267-
result->setFuncName(std::string(funcName.data, funcName.length));
268-
*options = wrap(result.release());
269-
return mtrtStatusGetOk();
270-
}
271-
272-
MTRT_Status mtrtStableHloProgramSignatureRefinementOptionsDestroy(
273-
MTRT_StableHLOProgramSignatureRefinementOptions options) {
274-
delete unwrap(options);
275-
return mtrtStatusGetOk();
276-
}
277-
278-
MTRT_Status mtrtGetStableHloProgramRefinedSignature(
279-
MTRT_CompilerClient client, MlirOperation module,
280-
MTRT_StableHLOProgramSignatureRefinementOptions options, MlirType *result) {
281-
ModuleOp moduleOp = llvm::dyn_cast<ModuleOp>(unwrap(module));
282-
if (!moduleOp)
283-
return mtrtStatusCreate(
284-
MTRT_StatusCode::MTRT_StatusCode_InvalidArgument,
285-
"StableHLO program signature refinement expects a ModuleOp");
286-
287-
StatusOr<FunctionType> funcType =
288-
compiler::getStableHLOProgramRefinedSignature(*unwrap(client), moduleOp,
289-
*unwrap(options));
290-
if (!funcType.isOk())
291-
return mtrtStatusCreate(MTRT_StatusCode::MTRT_StatusCode_InvalidArgument,
292-
funcType.getString().c_str());
293-
294-
*result = wrap(mlir::Type(*funcType));
295-
296-
return mtrtStatusGetOk();
297-
}

0 commit comments

Comments
 (0)