Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

mac m1 cross compile #1204

Merged
merged 9 commits into from
Aug 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 41 additions & 4 deletions .github/workflows/buildAndTest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ jobs:
fail-fast: true
matrix:
os: [macos-12, ubuntu-22.04]
targetarch: [x86_64, AArch64]
targetarch: [x86_64, arm64]
python-version: ["3.10"]
torch-binary: [ON, OFF]
llvmtype: [source, binary]
Expand All @@ -25,14 +25,17 @@ jobs:
- llvmtype: binary
llvmbuildtype: out-of-tree
# Disable M1 builds until https://github.com/llvm/torch-mlir/issues/1094 is fixed
- targetarch: AArch64
- targetarch: arm64
os: ubuntu-22.04
powderluv marked this conversation as resolved.
Show resolved Hide resolved
# macOS we only do source builds to reduce options
- os: macos-12
torch-binary: OFF
- os: macos-12
llvmtype: source
- os: macos-12
llvmtype: out-of-tree
- os: macos-12
targetarch: x86_64
runs-on: ${{ matrix.os }}

steps:
Expand All @@ -44,9 +47,37 @@ jobs:
with:
cache-suffix: ${{ matrix.os }}-${{ matrix.targetarch }}-${{ matrix.llvmtype }}-${{ matrix.llvmbuildtype }}

- name: Configure llvm-cross-compile
# libzstd on GH Runners are only x86_64 to remove them.
if: matrix.targetarch == 'arm64'
run: |
sudo rm -rf /usr/local/lib/libzstd.*.dylib
powderluv marked this conversation as resolved.
Show resolved Hide resolved
sudo rm -rf /usr/local/lib/cmake/zstd/*
cd $GITHUB_WORKSPACE
cmake -GNinja -Bbuild_${{ matrix.targetarch }} \
-DCMAKE_BUILD_TYPE=Release \
-DCMAKE_LINKER=lld \
-DCMAKE_C_COMPILER_LAUNCHER=ccache -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \
-DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ \
-DPython3_EXECUTABLE=$(which python) \
-DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_EXTERNAL_PROJECTS="torch-mlir;torch-mlir-dialects" \
-DLLVM_EXTERNAL_TORCH_MLIR_SOURCE_DIR="$GITHUB_WORKSPACE" \
-DLLVM_EXTERNAL_TORCH_MLIR_DIALECTS_SOURCE_DIR="${GITHUB_WORKSPACE}/external/llvm-external-projects/torch-mlir-dialects" \
-DMLIR_ENABLE_BINDINGS_PYTHON=ON \
-DTORCH_MLIR_ENABLE_LTC=OFF \
-DTORCH_MLIR_ENABLE_MHLO=OFF \
-DTORCH_MLIR_USE_INSTALLED_PYTORCH=${{ matrix.torch-binary }} \
-DCMAKE_OSX_ARCHITECTURES=${{ matrix.targetarch }} \
-DMACOSX_DEPLOYMENT_TARGET=12.0 \
-DLLVM_TARGETS_TO_BUILD="AArch64" \
-DLLVM_USE_HOST_TOOLS=ON \
$GITHUB_WORKSPACE/externals/llvm-project/llvm

- name: Configure llvm-binary-torch-src-or-binary
# Should be the fastest builds for CI and fails fast
# OSX CMake flags are ignore on Linux
# OSX CMake flags are ignored on Linux
if: matrix.llvmtype == 'binary'
run: |
cd $GITHUB_WORKSPACE
Expand Down Expand Up @@ -100,12 +131,18 @@ jobs:
-DTORCH_MLIR_USE_INSTALLED_PYTORCH=${{ matrix.torch-binary }} \
-DTORCH_MLIR_ENABLE_LTC=OFF \
-DPython3_EXECUTABLE=$(which python) \
-DLLVM_TARGETS_TO_BUILD=host \
.

- name: Build torch-mlir
# Build step for both in-tree and out-of-tree workflows
if: matrix.targetarch == 'x86_64'
run: |
cmake --build build

- name: Build torch-mlir (cross-compile)
if: matrix.targetarch == 'arm64'
run: |
cmake --build build_${{ matrix.targetarch }}

- name: Run torch-mlir unit tests
if: matrix.llvmtype == 'binary'
Expand Down
1 change: 0 additions & 1 deletion python/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,6 @@ set(_source_components
MLIRPythonSources
MLIRPythonExtension.Core
MLIRPythonExtension.RegisterEverything
MLIRPythonExtension.ExecutionEngine
TorchMLIRPythonSources
TorchMLIRPythonExtensions
)
Expand Down