From 1fab0d66951c31a885867fea0ea146ad83b6e9f0 Mon Sep 17 00:00:00 2001 From: Farid Zakaria Date: Sun, 14 Jan 2024 23:51:10 +0000 Subject: [PATCH] Changes to support new github action and configurable --- .github/workflows/publishWheelRelease.yml | 74 +++++++++++++++++++ build_tools/build_mlir.sh | 7 +- build_tools/github_actions/ci_build_cmake.sh | 7 +- .../github_actions/ci_build_cmake_llvm.sh | 7 +- 4 files changed, 88 insertions(+), 7 deletions(-) create mode 100644 .github/workflows/publishWheelRelease.yml diff --git a/.github/workflows/publishWheelRelease.yml b/.github/workflows/publishWheelRelease.yml new file mode 100644 index 00000000000..3294813ff34 --- /dev/null +++ b/.github/workflows/publishWheelRelease.yml @@ -0,0 +1,74 @@ +# Copyright 2023 The StableHLO Authors. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# https://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +name: Publish Python Wheel Release + +on: + push: + branches: [ main ] + workflow_dispatch: + +# Ensure that only a single job or workflow using the same +# concurrency group will run at a time. This would cancel +# any in-progress jobs in the same github workflow and github +# ref (e.g. refs/heads/main or refs/pull//merge). +concurrency: + group: ${{ github.workflow }}-${{ github.ref }} + cancel-in-progress: true + +jobs: + cmake-build: + # Only run scheduled CI on main repo + if: (github.repository == 'openxla/stablehlo' || github.event_name != 'schedule') + name: "cmake-build ${{ github.event_name == 'schedule' && '(llvm-project@HEAD)' || ''}}" + env: + LLVM_PROJECT_DIR: "llvm-project" + LLVM_BUILD_DIR: "llvm-build" + STABLEHLO_BUILD_DIR: "stablehlo-build" + strategy: + fail-fast: false + runs-on: ${{ github.repository == 'openxla/stablehlo' && 'ubuntu-22.04-64core' || 'ubuntu-22.04' }} + + steps: + - name: Checkout StableHLO + uses: actions/checkout@v4 + + - name: Get LLVM Version + id: llvm-version + shell: bash + run: | + echo "version=$(cat ${{ github.workspace }}/build_tools/llvm_version.txt)" >> $GITHUB_OUTPUT + + - name: Setup workspace + uses: ./.github/actions/setup-build + with: + llvm-version: ${{ steps.llvm-version.outputs.version }} + + - name: Configure and Build LLVM + shell: bash + run: | + ./build_tools/github_actions/ci_build_cmake_llvm.sh "$LLVM_PROJECT_DIR" "$LLVM_BUILD_DIR" + env: + CMAKE_BUILD_TYPE: Release + LLVM_ENABLE_BINDINGS: ON + + - name: Build and Test StableHLO with Python + shell: bash + run: | + ./build_tools/github_actions/ci_build_cmake.sh "$LLVM_BUILD_DIR" "$STABLEHLO_BUILD_DIR" + cd "$STABLEHLO_BUILD_DIR" + ninja check-stablehlo-python + env: + CMAKE_BUILD_TYPE: Release + LLVM_ENABLE_BINDINGS: ON \ No newline at end of file diff --git a/build_tools/build_mlir.sh b/build_tools/build_mlir.sh index c6ddab9a139..d829bc5cf21 100755 --- a/build_tools/build_mlir.sh +++ b/build_tools/build_mlir.sh @@ -23,7 +23,8 @@ fi # LLVM source LLVM_SRC_DIR="$1" build_dir="$2" -MLIR_CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-RelWithDebInfo}" +CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-RelWithDebInfo}" +LLVM_ENABLE_BINDINGS="${LLVM_ENABLE_BINDINGS:-OFF}" if ! [ -f "$LLVM_SRC_DIR/llvm/CMakeLists.txt" ]; then echo "Expected the path to LLVM to be set correctly (got '$LLVM_SRC_DIR'): can't find CMakeLists.txt" @@ -47,11 +48,11 @@ cmake -GNinja \ -DLLVM_ENABLE_PROJECTS=mlir \ -DLLVM_TARGETS_TO_BUILD=host \ -DLLVM_INCLUDE_TOOLS=ON \ - -DLLVM_ENABLE_BINDINGS=OFF \ + -DLLVM_ENABLE_BINDINGS="$LLVM_ENABLE_BINDINGS" \ -DMLIR_ENABLE_BINDINGS_PYTHON=ON \ -DLLVM_BUILD_TOOLS=OFF \ -DLLVM_INCLUDE_TESTS=OFF \ - -DCMAKE_BUILD_TYPE="$MLIR_CMAKE_BUILD_TYPE" \ + -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \ -DLLVM_ENABLE_ASSERTIONS=On cmake --build "$build_dir" --target all diff --git a/build_tools/github_actions/ci_build_cmake.sh b/build_tools/github_actions/ci_build_cmake.sh index 1a077b0e6c9..ea2a85a8947 100755 --- a/build_tools/github_actions/ci_build_cmake.sh +++ b/build_tools/github_actions/ci_build_cmake.sh @@ -27,19 +27,22 @@ fi LLVM_BUILD_DIR="$1" STABLEHLO_BUILD_DIR="$2" +CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-Release}" +STABLEHLO_ENABLE_BINDINGS_PYTHON="${STABLEHLO_ENABLE_BINDINGS_PYTHON:-OFF}" # Configure StableHLO cmake -GNinja \ -B"$STABLEHLO_BUILD_DIR" \ -DLLVM_ENABLE_LLD=ON \ - -DCMAKE_BUILD_TYPE=Release \ + -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \ -DLLVM_ENABLE_ASSERTIONS=On \ -DMLIR_DIR="$LLVM_BUILD_DIR/lib/cmake/mlir" \ -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ -DCMAKE_C_COMPILER=clang \ -DCMAKE_C_COMPILER_LAUNCHER=ccache \ - -DSTABLEHLO_ENABLE_STRICT_BUILD=On + -DSTABLEHLO_ENABLE_STRICT_BUILD=On \ + -DSTABLEHLO_ENABLE_BINDINGS_PYTHON="$STABLEHLO_ENABLE_BINDINGS_PYTHON" # Build and Test StableHLO cd "$STABLEHLO_BUILD_DIR" diff --git a/build_tools/github_actions/ci_build_cmake_llvm.sh b/build_tools/github_actions/ci_build_cmake_llvm.sh index 734b1e03ddf..51d3a13e939 100755 --- a/build_tools/github_actions/ci_build_cmake_llvm.sh +++ b/build_tools/github_actions/ci_build_cmake_llvm.sh @@ -25,6 +25,9 @@ fi LLVM_SRC_DIR="$1" LLVM_BUILD_DIR="$2" +CMAKE_BUILD_TYPE="${CMAKE_BUILD_TYPE:-RelWithDebInfo}" +LLVM_ENABLE_BINDINGS="${LLVM_ENABLE_BINDINGS:-OFF}" + # Configure LLVM cmake -GNinja \ "-H$LLVM_SRC_DIR/llvm" \ @@ -34,10 +37,10 @@ cmake -GNinja \ -DLLVM_ENABLE_PROJECTS=mlir \ -DLLVM_TARGETS_TO_BUILD=host \ -DLLVM_INCLUDE_TOOLS=ON \ - -DLLVM_ENABLE_BINDINGS=OFF \ + -DLLVM_ENABLE_BINDINGS="$LLVM_ENABLE_BINDINGS" \ -DLLVM_BUILD_TOOLS=OFF \ -DLLVM_INCLUDE_TESTS=OFF \ - -DCMAKE_BUILD_TYPE=RelWithDebInfo \ + -DCMAKE_BUILD_TYPE="$CMAKE_BUILD_TYPE" \ -DLLVM_ENABLE_ASSERTIONS=On \ -DCMAKE_CXX_COMPILER=clang++ \ -DCMAKE_CXX_COMPILER_LAUNCHER=ccache \