Add GetVocab DoFn in compile_modules_lib (#243) #720
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Copyright 2023 Google Inc. | |
# | |
# 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 | |
# | |
# http://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: Gematria CI | |
# The pinned version of LLVM. Must be manually updated to match the | |
# `LLVM_COMMIT` variable defined in `WORKSPACE`. | |
# TODO(virajbshah): Find a better way to keep these two in sync without the | |
# need to update one manually every time the other is changed. | |
env: | |
LLVM_COMMIT: 29b92d07746fac26cd64c914bc9c5c3833974f6d | |
on: | |
push: | |
branches: | |
- main | |
repository_dispatch: | |
pull_request: | |
jobs: | |
check-python-formatting: | |
name: Python Formatting Check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
- name: Install pyink | |
run: pip3 install pyink==23.9.1 | |
- name: Check python formatting | |
run: pyink --check --diff . | |
check-cpp-formatting: | |
name: C++ Formatting Check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Check c++ formatting | |
uses: jidicula/clang-format-action@v4.11.0 | |
with: | |
clang-format-version: '18' | |
check-path: 'src' | |
check-bazel-formatting: | |
name: Bazel Formatting Check | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: thompsonja/bazel-buildifier@v0.4.0 | |
with: | |
buildifier_version: v6.1.2 | |
check-cmake-projects: | |
name: Check CMake-based projects | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: hendrikmuhs/ccache-action@v1.2.14 | |
- uses: ConorMacBride/install-package@v1.1.0 | |
with: | |
apt: cmake ninja-build libpthreadpool-dev | |
- name: Get LLVM | |
run: | | |
git clone --depth 1 --no-checkout https://github.com/llvm/llvm-project.git /tmp/llvm-project | |
cd /tmp/llvm-project | |
git fetch --depth 1 origin $LLVM_COMMIT | |
git checkout $LLVM_COMMIT | |
- name: Set up TFLite | |
run: | | |
mkdir /tmp/tflite | |
cd /tmp/tflite | |
export CMAKE_CXX_COMPILER_LAUNCHER=ccache | |
export CMAKE_C_COMPILER_LAUNCHER=ccache | |
curl https://raw.githubusercontent.com/google/ml-compiler-opt/main/buildbot/build_tflite.sh | bash | |
- name: cmake setup | |
run: | | |
mkdir /tmp/cmake-build | |
cd /tmp/cmake-build | |
cmake -GNinja -DCMAKE_BUILD_TYPE=Release \ | |
-DLLVM_TARGETS_TO_BUILD=Native \ | |
-DCMAKE_C_COMPILER_LAUNCHER=ccache \ | |
-DCMAKE_CXX_COMPILER_LAUNCHER=ccache \ | |
-C /tmp/tflite/tflite.cmake \ | |
/tmp/llvm-project/llvm \ | |
-DLLVM_EXTERNAL_PROJECTS=gematria \ | |
-DLLVM_EXTERNAL_GEMATRIA_SOURCE_DIR=${{ github.workspace }} | |
- name: build | |
run: | | |
cd /tmp/cmake-build | |
ninja llvm-granite check-llvm-tools-llvm-cm | |
check-bazel: | |
name: Run bazel build | |
runs-on: ubuntu-latest | |
env: | |
USE_BAZEL_VERSION: 6.4.0 | |
strategy: | |
matrix: | |
build-config: [fastbuild, opt] | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Setup environment variables | |
run: echo "CURRENT_DAY=$(date +'%Y-%m-%d')" >> $GITHUB_ENV | |
- name: Setup LLVM | |
# TODO(boomanaiden154): We should refactor the docker image so we can | |
# have a base image with just system dependencies that we can then run | |
# everything in here to keep things consistent with less hacks. | |
run: | | |
sudo apt-get autoremove gcc-12 g++-12 && \ | |
echo "deb http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main\ndeb-src http://apt.llvm.org/jammy/ llvm-toolchain-jammy-19 main" | sudo tee /etc/apt/sources.list && \ | |
curl -L https://apt.llvm.org/llvm-snapshot.gpg.key | sudo apt-key add - && \ | |
curl -L https://apt.llvm.org/llvm-snapshot.gpg.key | sudo tee /etc/apt/trusted.gpg.d/apt.llvm.org.asc && \ | |
sudo apt-get update && \ | |
sudo apt-get install -y clang-19 lld-19 && \ | |
sudo rm -f /usr/bin/clang && \ | |
sudo rm -f /usr/bin/clang++ && \ | |
sudo ln -s /usr/bin/clang-19 /usr/bin/clang && \ | |
sudo ln -s /usr/bin/clang-19 /usr/bin/clang++ | |
- name: Cache Bazel | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.cache/bazel | |
key: ${{ runner.os }}-bazel-${{ matrix.build-config }}-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel') }}-${{ env.CURRENT_DAY }} | |
restore-keys: | | |
${{ runner.os }}-bazel-${{ matrix.build-config }}-${{ hashFiles('.bazelversion', '.bazelrc', 'WORKSPACE', 'WORKSPACE.bazel', 'MODULE.bazel') }} | |
${{ runner.os }}-bazel-${{ matrix.build-config }} | |
- name: Setup Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.10' | |
cache: 'pip' | |
- name: Install python deps | |
run: pip3 install -r requirements.txt | |
- name: Run build | |
run: bazel build -c ${{ matrix.build-config }} ... | |
- name: Run tests | |
run: bazel test -c ${{ matrix.build-config }} --test_tag_filters="-perf_counters" --test_output=errors ... | |