Skip to content

Commit

Permalink
Changes to support new github action and configurable
Browse files Browse the repository at this point in the history
  • Loading branch information
fzakaria committed Jan 14, 2024
1 parent 7125e7f commit 1fab0d6
Show file tree
Hide file tree
Showing 4 changed files with 88 additions and 7 deletions.
74 changes: 74 additions & 0 deletions .github/workflows/publishWheelRelease.yml
Original file line number Diff line number Diff line change
@@ -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/<pr_number>/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
7 changes: 4 additions & 3 deletions build_tools/build_mlir.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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
7 changes: 5 additions & 2 deletions build_tools/github_actions/ci_build_cmake.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
7 changes: 5 additions & 2 deletions build_tools/github_actions/ci_build_cmake_llvm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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" \
Expand All @@ -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 \
Expand Down

0 comments on commit 1fab0d6

Please sign in to comment.