Skip to content

Commit f1c36af

Browse files
committed
[CI] : Add customizations for ci build/test scripts.
1 parent 6b85cf8 commit f1c36af

File tree

4 files changed

+75
-34
lines changed

4 files changed

+75
-34
lines changed

build_tools/ci/build_posix.sh

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,19 +2,40 @@
22

33
set -eu -o errtrace
44

5-
this_dir="$(cd $(dirname $0) && pwd)"
6-
repo_root="$(cd $this_dir/../.. && pwd)"
7-
build_dir="$repo_root/build"
5+
this_dir="$(cd "$(dirname "$0")" && pwd)"
6+
repo_root="$(cd "$this_dir"/../.. && pwd)"
87
install_dir="$repo_root/install"
9-
mkdir -p "$build_dir"
10-
build_dir="$(cd $build_dir && pwd)"
118
cache_dir="${cache_dir:-}"
9+
build_dir="${build_dir:-}"
10+
torch_version="${1:-nightly}"
11+
12+
case $torch_version in
13+
nightly)
14+
build_dir_name=build
15+
;;
16+
stable)
17+
build_dir_name=build_stable
18+
;;
19+
*)
20+
echo "Unrecognized torch version '$torch_version' (specify 'nightly' or 'stable' with cl arg)"
21+
exit 1
22+
;;
23+
esac
24+
25+
# Setup build dir
26+
if [ -z "${build_dir}" ]; then
27+
build_dir="${repo_root}/${build_dir_name}"
28+
mkdir -p "$build_dir"
29+
build_dir="$(cd "${build_dir}" && pwd)"
30+
fi
31+
32+
echo "Building in ${build_dir}"
1233

1334
# Setup cache dir.
1435
if [ -z "${cache_dir}" ]; then
1536
cache_dir="${repo_root}/.build-cache"
1637
mkdir -p "${cache_dir}"
17-
cache_dir="$(cd ${cache_dir} && pwd)"
38+
cache_dir="$(cd "${cache_dir}" && pwd)"
1839
fi
1940
echo "Caching to ${cache_dir}"
2041
mkdir -p "${cache_dir}/ccache"
@@ -34,7 +55,7 @@ export CMAKE_CXX_COMPILER_LAUNCHER=ccache
3455
# Clear ccache stats.
3556
ccache -z
3657

37-
cd $repo_root
58+
cd "$repo_root"
3859

3960
echo "::group::CMake configure"
4061
cmake -S "$repo_root/externals/llvm-project/llvm" -B "$build_dir" \
@@ -59,7 +80,7 @@ cmake --build "$build_dir" --target tools/torch-mlir/all -- -k 0
5980
echo "::endgroup::"
6081

6182
echo "::group::Unit tests"
62-
cmake --build $repo_root/build --target check-torch-mlir-all
83+
cmake --build "$build_dir" --target check-torch-mlir-all
6384
echo "::endgroup::"
6485

6586
# Show ccache stats.

build_tools/ci/check_generated_sources.sh

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,15 @@
22

33
set -eu -o errtrace
44

5-
this_dir="$(cd $(dirname $0) && pwd)"
6-
repo_root="$(cd $this_dir/../.. && pwd)"
5+
this_dir="$(cd "$(dirname "$0")" && pwd)"
6+
repo_root="$(cd "$this_dir"/../.. && pwd)"
77

88
function _check_file_not_changed_by() {
99
# _check_file_not_changed_by <cmd> <file>
1010
cmd="$1"
1111
file="$2"
12-
file_backup="$PWD/$(basename $file)"
13-
file_new="$PWD/$(basename $file).new"
12+
file_backup="$PWD/$(basename "$file")"
13+
file_new="$PWD/$(basename "$file").new"
1414
# Save the original file.
1515
cp "$file" "$file_backup"
1616
# Run the command to regenerate it.
@@ -37,9 +37,9 @@ function _check_file_not_changed_by() {
3737
}
3838

3939
echo "::group:: Check that update_abstract_interp_lib.sh has been run"
40-
_check_file_not_changed_by $repo_root/build_tools/update_abstract_interp_lib.sh $repo_root/lib/Dialect/Torch/Transforms/AbstractInterpLibrary.cpp
40+
_check_file_not_changed_by "$repo_root"/build_tools/update_abstract_interp_lib.sh "$repo_root"/lib/Dialect/Torch/Transforms/AbstractInterpLibrary.cpp
4141
echo "::endgroup::"
4242

4343
echo "::group:: Check that update_torch_ods.sh has been run"
44-
_check_file_not_changed_by $repo_root/build_tools/update_torch_ods.sh $repo_root/include/torch-mlir/Dialect/Torch/IR/GeneratedTorchOps.td
44+
_check_file_not_changed_by "$repo_root"/build_tools/update_torch_ods.sh "$repo_root"/include/torch-mlir/Dialect/Torch/IR/GeneratedTorchOps.td
4545
echo "::endgroup::"

build_tools/ci/install_python_deps.sh

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,21 +2,30 @@
22

33
set -eu -o errtrace
44

5-
this_dir="$(cd $(dirname $0) && pwd)"
6-
repo_root="$(cd $this_dir/../.. && pwd)"
5+
this_dir="$(cd "$(dirname "$0")" && pwd)"
6+
repo_root="$(cd "$this_dir"/../.. && pwd)"
77
torch_version="${1:-unknown}"
88

9+
10+
echo "::group::upgrading pip"
11+
python3 -m pip install --upgrade pip
12+
echo "::endgroup::"
13+
14+
echo "::group::installing llvm python deps"
15+
python3 -m pip install --no-cache-dir -r "$repo_root"/externals/llvm-project/mlir/python/requirements.txt
16+
echo "::endgroup::"
17+
918
case $torch_version in
1019
nightly)
1120
echo "::group::installing nightly torch"
12-
python3 -m pip install --no-cache-dir -r $repo_root/requirements.txt
13-
python3 -m pip install --no-cache-dir -r $repo_root/torchvision-requirements.txt
21+
python3 -m pip install --no-cache-dir -r "$repo_root"/requirements.txt
22+
python3 -m pip install --no-cache-dir -r "$repo_root"/torchvision-requirements.txt
1423
echo "::endgroup::"
1524
;;
1625
stable)
1726
echo "::group::installing stable torch"
1827
python3 -m pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu
19-
python3 -m pip install --no-cache-dir -r $repo_root/build-requirements.txt
28+
python3 -m pip install --no-cache-dir -r "$repo_root"/build-requirements.txt
2029
echo "::endgroup::"
2130
;;
2231
*)
@@ -26,5 +35,5 @@ case $torch_version in
2635
esac
2736

2837
echo "::group::installing test requirements"
29-
python3 -m pip install --no-cache-dir -r $repo_root/test-requirements.txt
38+
python3 -m pip install --no-cache-dir -r "$repo_root"/test-requirements.txt
3039
echo "::endgroup::"

build_tools/ci/test_posix.sh

Lines changed: 25 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,36 @@
22

33
set -eu -o errtrace
44

5-
this_dir="$(cd $(dirname $0) && pwd)"
6-
repo_root="$(cd $this_dir/../.. && pwd)"
7-
torch_version="${1:-unknown}"
5+
this_dir="$(cd "$(dirname "$0")" && pwd)"
6+
repo_root="$(cd "$this_dir"/../.. && pwd)"
7+
torch_version="${1:-nightly}"
8+
build_dir="${build_dir:-}"
89

9-
export PYTHONPATH="$repo_root/build/tools/torch-mlir/python_packages/torch_mlir:$repo_root/projects/pt1"
10+
case $torch_version in
11+
nightly)
12+
build_dir_name=build
13+
;;
14+
stable)
15+
build_dir_name=build_stable
16+
;;
17+
*)
18+
echo "Unrecognized torch version '$torch_version' (specify 'nightly' or 'stable' with cl arg)"
19+
exit 1
20+
;;
21+
esac
22+
23+
if [ -z "${build_dir}" ]; then
24+
build_dir="${repo_root}/${build_dir_name}"
25+
build_dir="$(cd "${build_dir}" && pwd)"
26+
fi
27+
28+
export PYTHONPATH="$build_dir/tools/torch-mlir/python_packages/torch_mlir:$repo_root/projects/pt1"
1029

1130
echo "::group::Run ONNX e2e integration tests"
1231
python3 -m e2e_testing.main --config=onnx -v
1332
echo "::endgroup::"
1433

15-
case $torch_version in
16-
nightly)
34+
if [ "$torch_version" = "nightly" ]; then
1735
# Failing with: NotImplementedError:
1836
# Could not run 'aten::empty.memory_format' with arguments from the 'Lazy' backend.
1937
# As of 2024-01-07
@@ -35,11 +53,4 @@ case $torch_version in
3553
echo "::group::Run FxImporter TOSA e2e integration tests"
3654
python3 -m e2e_testing.main --config=fx_importer_tosa -v
3755
echo "::endgroup::"
38-
;;
39-
stable)
40-
;;
41-
*)
42-
echo "Unrecognized torch version '$torch_version' (specify 'nightly' or 'stable' with cl arg)"
43-
exit 1
44-
;;
45-
esac
56+
fi

0 commit comments

Comments
 (0)