Skip to content

Commit ad83c6d

Browse files
committed
[python wheel] : Ignore non-existing symlinks for python wheen creation.
1 parent c51c87f commit ad83c6d

File tree

8 files changed

+146
-9
lines changed

8 files changed

+146
-9
lines changed

build_tools/ci/install_python_deps.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ case $torch_version in
1919
;;
2020
stable)
2121
echo "::group::installing stable torch"
22-
# python3 -m pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu
22+
python3 -m pip install --no-cache-dir torch==2.5.1 torchvision --index-url https://download.pytorch.org/whl/cpu
2323
python3 -m pip install --no-cache-dir -r $repo_root/build-requirements.txt
2424
echo "::endgroup::"
2525
;;
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
#!/usr/bin/env bash
2+
set -eu -o errtrace
3+
4+
echo "Building torch-mlir"
5+
6+
cache_dir="${cache_dir:-}"
7+
this_dir="$(cd $(dirname $0) && pwd)"
8+
repo_root="$(cd ${this_dir}/../.. && pwd)"
9+
build_dir="${build_dir:-}"
10+
11+
# Setup cache dir.
12+
if [ -z "${cache_dir}" ]; then
13+
cache_dir="${repo_root}/.build-cache"
14+
mkdir -p "${cache_dir}"
15+
cache_dir="$(cd ${cache_dir} && pwd)"
16+
fi
17+
18+
if [ -z "${build_dir}" ]; then
19+
build_dir="${repo_root}/build"
20+
fi
21+
22+
echo "Building in ${build_dir}"
23+
24+
echo "Caching to ${cache_dir}"
25+
mkdir -p "${cache_dir}/ccache"
26+
mkdir -p "${cache_dir}/pip"
27+
28+
export CCACHE_DIR="${cache_dir}/ccache"
29+
export CCACHE_MAXSIZE="350M"
30+
31+
# Clear ccache stats.
32+
ccache -z
33+
34+
echo "::group::CMake configure"
35+
cmake -GNinja -B"${build_dir}" \
36+
-DCMAKE_BUILD_TYPE=Release \
37+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
38+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
39+
-DLLVM_ENABLE_PROJECTS=mlir \
40+
-DLLVM_TARGETS_TO_BUILD=host \
41+
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
42+
-DPython3_FIND_VIRTUALENV=ONLY \
43+
-DLLVM_EXTERNAL_PROJECTS="torch-mlir" \
44+
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$PWD" \
45+
-DPython3_EXECUTABLE="$(which python)" \
46+
-DPython_EXECUTABLE="$(which python)" \
47+
-DTORCH_MLIR_ENABLE_STABLEHLO=OFF \
48+
-DTORCH_MLIR_ENABLE_PYTORCH_EXTENSIONS=ON \
49+
-DTORCH_MLIR_ENABLE_LTC=OFF \
50+
-DTORCH_MLIR_ENABLE_JIT_IR_IMPORTER=ON \
51+
"${repo_root}"/externals/llvm-project/llvm
52+
echo "::endgroup::"
53+
54+
echo "::group::Build"
55+
cmake --build "${build_dir}" --target tools/torch-mlir/all -- -k 0
56+
echo "::endgroup::"
57+
58+
echo "Build completed successfully"
59+
60+
# echo "::group::Unit tests"
61+
# cmake --build "${build_dir}" --target check-torch-mlir
62+
# echo "::endgroup::"
63+
64+
# Show ccache stats.
65+
ccache --show-stats

build_tools/python_deploy/build_linux_packages.sh

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -347,7 +347,7 @@ function setup_venv() {
347347
;;
348348
stable)
349349
echo ":::: Using stable dependencies"
350-
python3 -m pip install --no-cache-dir torch torchvision --index-url https://download.pytorch.org/whl/cpu
350+
python3 -m pip install --no-cache-dir torch==2.5.1 torchvision --index-url https://download.pytorch.org/whl/cpu
351351
python3 -m pip install --no-cache-dir -r /main_checkout/torch-mlir/build-requirements.txt
352352
;;
353353
*)
@@ -471,6 +471,8 @@ function build_torch_mlir() {
471471
# Disable LTC build for releases
472472
export TORCH_MLIR_ENABLE_LTC=0
473473
python -m pip install --no-cache-dir -r /main_checkout/torch-mlir/build-requirements.txt
474+
475+
echo ":::: Creating WHEEEEEEEEEEEEEEEEEEEEEELLLLLLLLLLLLLLLLLLLLL"
474476
CMAKE_GENERATOR=Ninja \
475477
TORCH_MLIR_PYTHON_PACKAGE_VERSION=${TORCH_MLIR_PYTHON_PACKAGE_VERSION} \
476478
TORCH_MLIR_ENABLE_JIT_IR_IMPORTER=0 \
Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
#!/usr/bin/env bash
2+
set -eu -o errtrace
3+
4+
echo "Building torch-mlir"
5+
6+
cache_dir="${cache_dir:-}"
7+
this_dir="$(cd $(dirname $0) && pwd)"
8+
repo_root="$(cd ${this_dir}/../.. && pwd)"
9+
build_dir="${build_dir:-}"
10+
11+
12+
# Setup cache dir.
13+
if [ -z "${cache_dir}" ]; then
14+
cache_dir="${repo_root}/.build-cache"
15+
mkdir -p "${cache_dir}"
16+
cache_dir="$(cd ${cache_dir} && pwd)"
17+
fi
18+
19+
if [ -z "${build_dir}" ]; then
20+
build_dir="${repo_root}/build"
21+
fi
22+
23+
echo "Building in ${build_dir}"
24+
25+
echo "Caching to ${cache_dir}"
26+
mkdir -p "${cache_dir}/ccache"
27+
mkdir -p "${cache_dir}/pip"
28+
29+
export CCACHE_DIR="${cache_dir}/ccache"
30+
export CCACHE_MAXSIZE="350M"
31+
32+
# Clear ccache stats.
33+
ccache -z
34+
35+
echo "::group::CMake configure"
36+
cmake -GNinja -B"${build_dir}" \
37+
-DCMAKE_BUILD_TYPE=Release \
38+
-DCMAKE_C_COMPILER_LAUNCHER=ccache \
39+
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
40+
-DLLVM_ENABLE_PROJECTS=mlir \
41+
-DLLVM_TARGETS_TO_BUILD=host \
42+
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
43+
-DPython3_FIND_VIRTUALENV=ONLY \
44+
-DLLVM_EXTERNAL_PROJECTS="torch-mlir" \
45+
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$PWD" \
46+
-DPython3_EXECUTABLE="$(which python)" \
47+
-DPython_EXECUTABLE="$(which python)" \
48+
-DTORCH_MLIR_ENABLE_STABLEHLO=OFF \
49+
-DTORCH_MLIR_ENABLE_PYTORCH_EXTENSIONS=ON \
50+
-DTORCH_MLIR_ENABLE_LTC=OFF \
51+
-DTORCH_MLIR_ENABLE_JIT_IR_IMPORTER=ON \
52+
"${repo_root}"/externals/llvm-project/llvm
53+
echo "::endgroup::"
54+
55+
echo "::group::Build"
56+
cmake --build "${build_dir}" --target tools/torch-mlir/all -- -k 0
57+
echo "::endgroup::"
58+
59+
echo "Build completed successfully"
60+
61+
# echo "::group::Unit tests"
62+
# cmake --build "${build_dir}" --target check-torch-mlir
63+
# echo "::endgroup::"
64+
65+
# Show ccache stats.
66+
ccache --show-stats

build_tools/python_deploy/build_windows_ci.sh

100644100755
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -51,9 +51,9 @@ echo "::endgroup::"
5151

5252
echo "Build completed successfully"
5353

54-
echo "::group::Unit tests"
55-
cmake --build ${repo_root}/build --target check-torch-mlir
56-
echo "::endgroup::"
54+
# echo "::group::Unit tests"
55+
# cmake --build ${repo_root}/build --target check-torch-mlir
56+
# echo "::endgroup::"
5757

5858
# Show ccache stats.
5959
ccache --show-stats

lib/Dialect/TorchConversion/Transforms/VerifyTosaLinalgBackendContract.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,12 +82,10 @@ class VerifyTosaLinalgBackendContractPass
8282
target.addDynamicallyLegalDialect<complex::ComplexDialect>(isLegalScalarOp);
8383

8484
// Tensor operations should go through linalg and the tensor dialect.
85-
8685
target.addDynamicallyLegalDialect<linalg::LinalgDialect>(opHasLegalTypes);
8786
target.addDynamicallyLegalDialect<sparse_tensor::SparseTensorDialect>(
8887
opHasLegalTypes);
8988
target.addDynamicallyLegalDialect<tensor::TensorDialect>(opHasLegalTypes);
90-
target.addDynamicallyLegalDialect<tosa::TosaDialect>(opHasLegalTypes);
9189
target.addDynamicallyLegalDialect<affine::AffineDialect>(opHasLegalTypes);
9290
target.addDynamicallyLegalDialect<cf::ControlFlowDialect>(opHasLegalTypes);
9391
target.addDynamicallyLegalDialect<scf::SCFDialect>(opHasLegalTypes);
@@ -99,6 +97,9 @@ class VerifyTosaLinalgBackendContractPass
9997
target.addDynamicallyLegalOp<arith::ConstantOp>(opHasLegalTypes);
10098
target.addDynamicallyLegalOp<complex::CreateOp>(opHasLegalTypes);
10199

100+
// Any TosaOp is valid
101+
target.addLegalDialect<tosa::TosaDialect>();
102+
102103
RewritePatternSet patterns(context);
103104
if (failed(applyFullConversion(module, target, std::move(patterns)))) {
104105
// We avoid `module.emitError()` so that mlir-print-op-on-diagnostics

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,4 @@ build-backend = "setuptools.build_meta"
44

55
[tool.black]
66
line-length = 88
7-
target-version = ['py38']
7+
target-version = ['py311']

setup.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,10 @@ def run(self):
199199
if os.path.exists(target_dir):
200200
shutil.rmtree(target_dir, ignore_errors=False, onerror=None)
201201

202-
shutil.copytree(python_package_dir, target_dir, symlinks=False)
202+
python_package_dir = os.path.join(python_package_dir, "torch_mlir")
203+
shutil.copytree(
204+
python_package_dir, os.path.join(target_dir, "torch_mlir"), symlinks=False
205+
)
203206

204207
torch_mlir_opt_src = os.path.join(cmake_build_dir, "bin", "torch-mlir-opt")
205208
torch_mlir_opt_dst = os.path.join(

0 commit comments

Comments
 (0)