Skip to content

[tensorrt] Refine types for tensorrt ops with plan.with_shape #136

[tensorrt] Refine types for tensorrt ops with plan.with_shape

[tensorrt] Refine types for tensorrt ops with plan.with_shape #136

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
# Run initial format check
- name: Run commit message, python format, and c++ clang format 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 commit message is in the canonical format
# 2. Check if Python files follow black format
# 3. 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 > commit_message_checker.py <<EOF
#!/usr/bin/python3
import re
import sys
match = re.search(r"^(\[bot\].+|NFC: .+|(.+\n\n+.+\n+.+))$", sys.argv[1], re.DOTALL)
if match:
sys.exit(0)
sys.exit(1)
EOF
cat > run_format_check.sh <<EOF
#!/bin/bash
set -e
head_commit_message=$(git rev-list --max-count=1 --format=%B --no-commit-header HEAD)
python3 commit_message_checker.py "$head_commit_message"
if [[ $? == 0 ]] ; then
echo "Commit message is in the canonical form :)"
else
echo "Commit message is not in the canonical form!"
echo "${head_commit_message}"
echo ""
echo "Expected format is, "
echo "<subject>"
echo ""
echo "<body>"
echo "body should be at least two lines."
exit 1
fi
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
- name: Run MLIR-TensorRT lit tests
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