Update llvm commit ID to 1d01fc1 (#292)

* Fix for LLVM revision D85495

* Fix for LLVM revision DD86121

* Fix for LLVM revision D85622 (f9dc2b7)
TODO: Change preloadDialectsInContext to false

Memo for previous fixes: D86121 (250f43d), D85495 (575b22b)

* clang-format

* Update llvm commit ID of README and clone-mlir.sh

* Updated llvm commit ID of README.md

* Fix for passing backend tests

* Removed the commented code

* Empty commit for triggering rebuild

* Test multi-stage travis build

* Specify stage order.

* Empty commit for triggering rebuild

* Update prereq.s390x.Dockerfile

Make it possible to execute s390x prereq docker multiple times.

* Build prereq for each arch

* Fix multi-arch prereq build.

* timeout at 40m

* Update .travis.yml

* add ppc64le prereq builder

* Run ppc docker prereq build multiple times

* Do not test branch update unless it's mater.

* Fix dockerfile.

* Fix typo in travis.yml.

* Fix ppc64 docker file

* Update .travis.yml

* turn off metacopy on ppc64le

* Update .travis.yml

* Turn off metacopy.

* Turn off metacopy inside Dockerfile in ppc64.

* No sudo in Docker.

* Remove metacopy config from Dockerfile.

* Change base image to be bionic.

* Using newer linux distro for ppc64.

* Turn off metacopy in before_install.

* Fix sudo permission issue.

* Run docker info.

* Allow amd64 docker file to be built multiple times

* Support building amd64 prereq.

* Fix amd64 docker file typo.

* fix ppc64le dockerfile typo.

* timeout from 40m -> 30m

* 40m->30m

* 40m->30m

* fix bug preventing incremental build.

* fix bug preventing incremental build.

* Bump CircleCI cache version.

* Push to production prereq container repository and condition prereq docker rebuild on commit message.

* Rebuild prereq docker.

* Move default script to top-level.

* Python not properly installed.

* amd64 -> x86

* Rebuild prereq docker.

* Rebuild prereq docker.

* Rebuild prereq docker.

* Restart all CI.

* Disallow cache on Jenkins docker build.

* Restart zJenkins.

* Restart zJenkins.

Co-authored-by: Haruki Imai <imaihal@jp.ibm.com>
Co-authored-by: Alexandre Eichenberger <alexe@us.ibm.com>
This commit is contained in:
Tian Jin 2020-09-09 23:12:01 +08:00 committed by GitHub
parent c738e0fb07
commit dbc41d2330
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 440 additions and 275 deletions

View File

@ -18,7 +18,7 @@ jobs:
git submodule update --init --recursive git submodule update --init --recursive
# Use cached mlir installation if possible. # Use cached mlir installation if possible.
- restore_cache: - restore_cache:
key: V17-LLVM-PROJECT-{{ arch }} key: V18-LLVM-PROJECT-{{ arch }}
- run: - run:
name: Install MLIR name: Install MLIR
command: | command: |
@ -29,7 +29,7 @@ jobs:
source onnx-mlir/utils/install-mlir.sh source onnx-mlir/utils/install-mlir.sh
fi fi
- save_cache: - save_cache:
key: V17-LLVM-PROJECT-{{ arch }} key: V18-LLVM-PROJECT-{{ arch }}
paths: paths:
- llvm-project - llvm-project
- run: - run:

View File

@ -11,9 +11,17 @@ arch:
env: env:
- NIGHTLY=true - NIGHTLY=true
- NIGHTLY=false - NIGHTLY=false
jobs: # Do not test branch update unless it's mater.
allow_failures: branches:
- env: NIGHTLY=true only:
- master
stages:
- name: prereq-init
- name: prereq-0
- name: prereq-1
- name: prereq-2
- name: prereq-final
- name: test
script: script:
- export CPU_ARCH=$TRAVIS_CPU_ARCH - export CPU_ARCH=$TRAVIS_CPU_ARCH
- if [ "$CPU_ARCH" == "amd64" ] ; then - if [ "$CPU_ARCH" == "amd64" ] ; then
@ -42,6 +50,148 @@ script:
- docker exec build compile-onnx-mlir.sh - docker exec build compile-onnx-mlir.sh
- docker exec build test-onnx-mlir.sh - docker exec build test-onnx-mlir.sh
- docker commit build onnxmlirczar/onnx-mlir-build:$CPU_ARCH - docker commit build onnxmlirczar/onnx-mlir-build:$CPU_ARCH
jobs:
allow_failures:
- env: NIGHTLY=true
include:
##########################################################################################
#
# Incrementally build s390 prereq docker images through 5 time-constrained steps.
#
##########################################################################################
- stage: prereq-init
if: commit_message = "Rebuild prereq docker."
arch:
- s390x
script:
- docker build -t onnxmlirczar/onnx-mlir-llvmimage-partial:s390x -f docker/prereq.s390x.Dockerfile --build-arg BASE_IMAGE="ubuntu:focal" ./utils
- docker login -u onnxmlirczar -p "$DOCKER_HUB_TOKEN"
- docker push onnxmlirczar/onnx-mlir-llvmimage-partial:s390x
- stage: prereq-0
if: commit_message = "Rebuild prereq docker."
arch:
- s390x
script:
- docker build -t onnxmlirczar/onnx-mlir-llvmimage-partial:s390x -f docker/prereq.s390x.Dockerfile --build-arg BASE_IMAGE="onnxmlirczar/onnx-mlir-llvmimage-partial:s390x" ./utils
- docker login -u onnxmlirczar -p "$DOCKER_HUB_TOKEN"
- docker push onnxmlirczar/onnx-mlir-llvmimage-partial:s390x
- stage: prereq-1
if: commit_message = "Rebuild prereq docker."
arch:
- s390x
script:
- docker build -t onnxmlirczar/onnx-mlir-llvmimage-partial:s390x -f docker/prereq.s390x.Dockerfile --build-arg BASE_IMAGE="onnxmlirczar/onnx-mlir-llvmimage-partial:s390x" ./utils
- docker login -u onnxmlirczar -p "$DOCKER_HUB_TOKEN"
- docker push onnxmlirczar/onnx-mlir-llvmimage-partial:s390x
- stage: prereq-2
if: commit_message = "Rebuild prereq docker."
arch:
- s390x
script:
- docker build -t onnxmlirczar/onnx-mlir-llvmimage-partial:s390x -f docker/prereq.s390x.Dockerfile --build-arg BASE_IMAGE="onnxmlirczar/onnx-mlir-llvmimage-partial:s390x" ./utils
- docker login -u onnxmlirczar -p "$DOCKER_HUB_TOKEN"
- docker push onnxmlirczar/onnx-mlir-llvmimage-partial:s390x
- stage: prereq-final
if: commit_message = "Rebuild prereq docker."
arch:
- s390x
script:
- docker build -t onnxmlirczar/onnx-mlir-llvmimage:s390x -f docker/prereq.s390x.Dockerfile --build-arg BASE_IMAGE="onnxmlirczar/onnx-mlir-llvmimage-partial:s390x" ./utils
- docker login -u onnxmlirczar -p "$DOCKER_HUB_TOKEN"
- docker push onnxmlirczar/onnx-mlir-llvmimage:s390x
##########################################################################################
#
# Incrementally build ppc64le prereq docker images through 5 time-constrained steps.
#
##########################################################################################
- stage: prereq-init
if: commit_message = "Rebuild prereq docker."
arch:
- ppc64le
script:
- docker build -t onnxmlirczar/onnx-mlir-llvmimage-partial:ppc64le -f docker/prereq.ppc64le.Dockerfile --build-arg BASE_IMAGE="ubuntu:bionic" ./utils
- docker login -u onnxmlirczar -p "$DOCKER_HUB_TOKEN"
- docker push onnxmlirczar/onnx-mlir-llvmimage-partial:ppc64le
- stage: prereq-0
if: commit_message = "Rebuild prereq docker."
arch:
- ppc64le
script:
- docker build -t onnxmlirczar/onnx-mlir-llvmimage-partial:ppc64le -f docker/prereq.ppc64le.Dockerfile --build-arg BASE_IMAGE="onnxmlirczar/onnx-mlir-llvmimage-partial:ppc64le" ./utils
- docker login -u onnxmlirczar -p "$DOCKER_HUB_TOKEN"
- docker push onnxmlirczar/onnx-mlir-llvmimage-partial:ppc64le
- stage: prereq-1
if: commit_message = "Rebuild prereq docker."
arch:
- ppc64le
script:
- docker build -t onnxmlirczar/onnx-mlir-llvmimage-partial:ppc64le -f docker/prereq.ppc64le.Dockerfile --build-arg BASE_IMAGE="onnxmlirczar/onnx-mlir-llvmimage-partial:ppc64le" ./utils
- docker login -u onnxmlirczar -p "$DOCKER_HUB_TOKEN"
- docker push onnxmlirczar/onnx-mlir-llvmimage-partial:ppc64le
- stage: prereq-2
if: commit_message = "Rebuild prereq docker."
arch:
- ppc64le
script:
- docker build -t onnxmlirczar/onnx-mlir-llvmimage-partial:ppc64le -f docker/prereq.ppc64le.Dockerfile --build-arg BASE_IMAGE="onnxmlirczar/onnx-mlir-llvmimage-partial:ppc64le" ./utils
- docker login -u onnxmlirczar -p "$DOCKER_HUB_TOKEN"
- docker push onnxmlirczar/onnx-mlir-llvmimage-partial:ppc64le
- stage: prereq-final
if: commit_message = "Rebuild prereq docker."
arch:
- ppc64le
script:
- docker build -t onnxmlirczar/onnx-mlir-llvmimage:ppc64le -f docker/prereq.ppc64le.Dockerfile --build-arg BASE_IMAGE="onnxmlirczar/onnx-mlir-llvmimage-partial:ppc64le" ./utils
- docker login -u onnxmlirczar -p "$DOCKER_HUB_TOKEN"
- docker push onnxmlirczar/onnx-mlir-llvmimage:ppc64le
##########################################################################################
#
# Incrementally build amd64 prereq docker images through 5 time-constrained steps.
#
##########################################################################################
- stage: prereq-init
if: commit_message = "Rebuild prereq docker."
arch:
- amd64
script:
- docker build -t onnxmlirczar/onnx-mlir-llvmimage-partial:x86 -f docker/prereq.amd64.Dockerfile --build-arg BASE_IMAGE="ubuntu:focal" ./utils
- docker login -u onnxmlirczar -p "$DOCKER_HUB_TOKEN"
- docker push onnxmlirczar/onnx-mlir-llvmimage-partial:x86
- stage: prereq-0
if: commit_message = "Rebuild prereq docker."
arch:
- amd64
script:
- docker build -t onnxmlirczar/onnx-mlir-llvmimage-partial:x86 -f docker/prereq.amd64.Dockerfile --build-arg BASE_IMAGE="onnxmlirczar/onnx-mlir-llvmimage-partial:x86" ./utils
- docker login -u onnxmlirczar -p "$DOCKER_HUB_TOKEN"
- docker push onnxmlirczar/onnx-mlir-llvmimage-partial:x86
- stage: prereq-1
if: commit_message = "Rebuild prereq docker."
arch:
- amd64
script:
- docker build -t onnxmlirczar/onnx-mlir-llvmimage-partial:x86 -f docker/prereq.amd64.Dockerfile --build-arg BASE_IMAGE="onnxmlirczar/onnx-mlir-llvmimage-partial:x86" ./utils
- docker login -u onnxmlirczar -p "$DOCKER_HUB_TOKEN"
- docker push onnxmlirczar/onnx-mlir-llvmimage-partial:x86
- stage: prereq-2
if: commit_message = "Rebuild prereq docker."
arch:
- amd64
script:
- docker build -t onnxmlirczar/onnx-mlir-llvmimage-partial:x86 -f docker/prereq.amd64.Dockerfile --build-arg BASE_IMAGE="onnxmlirczar/onnx-mlir-llvmimage-partial:x86" ./utils
- docker login -u onnxmlirczar -p "$DOCKER_HUB_TOKEN"
- docker push onnxmlirczar/onnx-mlir-llvmimage-partial:x86
- stage: prereq-final
if: commit_message = "Rebuild prereq docker."
arch:
- amd64
script:
- docker build -t onnxmlirczar/onnx-mlir-llvmimage:x86 -f docker/prereq.amd64.Dockerfile --build-arg BASE_IMAGE="onnxmlirczar/onnx-mlir-llvmimage-partial:x86" ./utils
- docker login -u onnxmlirczar -p "$DOCKER_HUB_TOKEN"
- docker push onnxmlirczar/onnx-mlir-llvmimage:x86
after_success: after_success:
- if [ $TRAVIS_PULL_REQUEST == false ] && [ $TRAVIS_BRANCH == "master" ] && [ $NIGHTLY == false ]; then - if [ $TRAVIS_PULL_REQUEST == false ] && [ $TRAVIS_BRANCH == "master" ] && [ $NIGHTLY == false ]; then
echo "Pushing new build to docker hub"; echo "Pushing new build to docker hub";

View File

@ -253,8 +253,8 @@ set(MLIRLibs
${MLIRSideEffectInterfaces} ${MLIRSideEffectInterfaces}
${MLIRStandardOps} ${MLIRStandardOps}
${MLIRStandardToLLVM} ${MLIRStandardToLLVM}
${MLIRSupport}
${MLIRTranslation} ${MLIRTranslation}
${MLIRSupport}
${MLIRLinalgOps} ${MLIRLinalgOps}
${MLIRLinalgEDSC} ${MLIRLinalgEDSC}
${MLIRLinalgAnalysis} ${MLIRLinalgAnalysis}

View File

@ -62,7 +62,7 @@ Firstly, install MLIR (as a part of LLVM-Project):
``` bash ``` bash
git clone https://github.com/llvm/llvm-project.git git clone https://github.com/llvm/llvm-project.git
# Check out a specific branch that is known to work with ONNX MLIR. # Check out a specific branch that is known to work with ONNX MLIR.
cd llvm-project && git checkout 9c94908320549a1a2328c758d6bbb694466021e7 && cd .. cd llvm-project && git checkout 1d01fc100bb5bef5f5eaf92520b2e52f64ee1d6e && cd ..
``` ```
[same-as-file]: <> (utils/build-mlir.sh) [same-as-file]: <> (utils/build-mlir.sh)
@ -152,7 +152,7 @@ Install MLIR (as a part of LLVM-Project):
```shell ```shell
git clone https://github.com/llvm/llvm-project.git git clone https://github.com/llvm/llvm-project.git
# Check out a specific branch that is known to work with ONNX MLIR. # Check out a specific branch that is known to work with ONNX MLIR.
cd llvm-project && git checkout 9c94908320549a1a2328c758d6bbb694466021e7 && cd .. cd llvm-project && git checkout 1d01fc100bb5bef5f5eaf92520b2e52f64ee1d6e && cd ..
``` ```
[same-as-file]: <> (utils/build-mlir.cmd) [same-as-file]: <> (utils/build-mlir.cmd)

View File

@ -1,4 +1,7 @@
FROM ubuntu:focal ARG BASE_IMAGE
# By default, use ubuntu:focal;
FROM $BASE_IMAGE
WORKDIR /build WORKDIR /build
@ -11,33 +14,43 @@ RUN DEBIAN_FRONTEND=noninteractive \
make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev \ make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev \
libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils \ libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils \
libffi-dev liblzma-dev libffi-dev liblzma-dev
RUN git clone git://github.com/yyuu/pyenv.git .pyenv
RUN git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv RUN if [ ! -d .pyenv ]; then \
git clone git://github.com/yyuu/pyenv.git .pyenv && \
git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv; \
fi
ENV HOME=/build ENV HOME=/build
ENV PYENV_ROOT=$HOME/.pyenv ENV PYENV_ROOT=$HOME/.pyenv
ENV PATH=$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH ENV PATH=$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
RUN pyenv install 3.7.0 RUN if [ ! -f "./pyenv-installed" ]; then \
pyenv install 3.7.0 && \
RUN pyenv global 3.7.0 pyenv global 3.7.0 && \
RUN pyenv rehash pyenv rehash && \
touch ./pyenv-installed; \
fi
# first install MLIR in llvm-project # first install MLIR in llvm-project
RUN mkdir bin RUN mkdir -p bin
ENV PATH=$PATH:/build/bin ENV PATH=$PATH:/build/bin
COPY clone-mlir.sh bin/clone-mlir.sh COPY clone-mlir.sh bin/clone-mlir.sh
RUN chmod a+x bin/clone-mlir.sh RUN chmod a+x bin/clone-mlir.sh
RUN clone-mlir.sh RUN if [ ! -d /build/llvm-project ]; then \
clone-mlir.sh; \
fi
WORKDIR /build/llvm-project/build WORKDIR /build/llvm-project/build
RUN cmake -G Ninja ../llvm \ RUN if [ ! -f "/build/llvm-project/build/CMakeCache.txt" ]; then \
cmake -G Ninja ../llvm \
-DLLVM_ENABLE_PROJECTS=mlir \ -DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_BUILD_EXAMPLES=ON \ -DLLVM_BUILD_EXAMPLES=ON \
-DLLVM_TARGETS_TO_BUILD="host" \ -DLLVM_TARGETS_TO_BUILD="host" \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \ -DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_RTTI=ON -DLLVM_ENABLE_RTTI=ON; \
fi
RUN cmake --build . --target -- ${MAKEFLAGS} RUN if timeout 30m cmake --build . --target -- ${MAKEFLAGS} ; then \
RUN cmake --build . --target check-mlir cmake --build . --target check-mlir; \
fi

View File

@ -1,4 +1,7 @@
FROM ubuntu:focal ARG BASE_IMAGE
# By default, use ubuntu:focal;
FROM $BASE_IMAGE
WORKDIR /build WORKDIR /build
@ -11,33 +14,43 @@ RUN DEBIAN_FRONTEND=noninteractive \
make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev \ make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev \
libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils \ libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils \
libffi-dev liblzma-dev libffi-dev liblzma-dev
RUN git clone git://github.com/yyuu/pyenv.git .pyenv
RUN git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv RUN if [ ! -d .pyenv ]; then \
git clone git://github.com/yyuu/pyenv.git .pyenv && \
git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv; \
fi
ENV HOME=/build ENV HOME=/build
ENV PYENV_ROOT=$HOME/.pyenv ENV PYENV_ROOT=$HOME/.pyenv
ENV PATH=$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH ENV PATH=$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
RUN pyenv install 3.7.0 RUN if [ ! -f "./pyenv-installed" ]; then \
pyenv install 3.7.0 && \
RUN pyenv global 3.7.0 pyenv global 3.7.0 && \
RUN pyenv rehash pyenv rehash && \
touch ./pyenv-installed; \
fi
# first install MLIR in llvm-project # first install MLIR in llvm-project
RUN mkdir bin RUN mkdir -p bin
ENV PATH=$PATH:/build/bin ENV PATH=$PATH:/build/bin
COPY clone-mlir.sh bin/clone-mlir.sh COPY clone-mlir.sh bin/clone-mlir.sh
RUN chmod a+x bin/clone-mlir.sh RUN chmod a+x bin/clone-mlir.sh
RUN clone-mlir.sh RUN if [ ! -d /build/llvm-project ]; then \
clone-mlir.sh; \
fi
WORKDIR /build/llvm-project/build WORKDIR /build/llvm-project/build
RUN cmake -G Ninja ../llvm \ RUN if [ ! -f "/build/llvm-project/build/CMakeCache.txt" ]; then \
cmake -G Ninja ../llvm \
-DLLVM_ENABLE_PROJECTS=mlir \ -DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_BUILD_EXAMPLES=ON \ -DLLVM_BUILD_EXAMPLES=ON \
-DLLVM_TARGETS_TO_BUILD="host" \ -DLLVM_TARGETS_TO_BUILD="host" \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \ -DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_RTTI=ON -DLLVM_ENABLE_RTTI=ON; \
fi
RUN cmake --build . --target -- ${MAKEFLAGS} RUN if timeout 30m cmake --build . --target -- ${MAKEFLAGS} ; then \
RUN cmake --build . --target check-mlir cmake --build . --target check-mlir; \
fi

View File

@ -1,4 +1,7 @@
FROM ubuntu:focal ARG BASE_IMAGE
# By default, use ubuntu:focal;
FROM $BASE_IMAGE
WORKDIR /build WORKDIR /build
@ -11,33 +14,44 @@ RUN DEBIAN_FRONTEND=noninteractive \
make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev \ make build-essential libssl-dev zlib1g-dev libbz2-dev libreadline-dev \
libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils \ libsqlite3-dev wget curl llvm libncurses5-dev libncursesw5-dev xz-utils \
libffi-dev liblzma-dev libffi-dev liblzma-dev
RUN git clone git://github.com/yyuu/pyenv.git .pyenv
RUN git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv RUN if [ ! -d .pyenv ]; then \
git clone git://github.com/yyuu/pyenv.git .pyenv && \
git clone https://github.com/yyuu/pyenv-virtualenv.git ~/.pyenv/plugins/pyenv-virtualenv; \
fi
ENV HOME=/build ENV HOME=/build
ENV PYENV_ROOT=$HOME/.pyenv ENV PYENV_ROOT=$HOME/.pyenv
ENV PATH=$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH ENV PATH=$PYENV_ROOT/shims:$PYENV_ROOT/bin:$PATH
RUN pyenv install 3.7.0 RUN if [ ! -f "./pyenv-installed" ]; then \
pyenv install 3.7.0 && \
RUN pyenv global 3.7.0 pyenv global 3.7.0 && \
RUN pyenv rehash pyenv rehash && \
touch ./pyenv-installed; \
fi
# first install MLIR in llvm-project # first install MLIR in llvm-project
RUN mkdir bin RUN mkdir -p bin
ENV PATH=$PATH:/build/bin ENV PATH=$PATH:/build/bin
COPY clone-mlir.sh bin/clone-mlir.sh COPY clone-mlir.sh bin/clone-mlir.sh
RUN chmod a+x bin/clone-mlir.sh RUN chmod a+x bin/clone-mlir.sh
RUN clone-mlir.sh RUN if [ ! -d /build/llvm-project ]; then \
clone-mlir.sh; \
fi
WORKDIR /build/llvm-project/build WORKDIR /build/llvm-project/build
RUN cmake -G Ninja ../llvm \ RUN if [ ! -f "/build/llvm-project/build/CMakeCache.txt" ]; then \
cmake -G Ninja ../llvm \
-DLLVM_ENABLE_PROJECTS=mlir \ -DLLVM_ENABLE_PROJECTS=mlir \
-DLLVM_BUILD_EXAMPLES=ON \ -DLLVM_BUILD_EXAMPLES=ON \
-DLLVM_TARGETS_TO_BUILD="host" \ -DLLVM_TARGETS_TO_BUILD="host" \
-DCMAKE_BUILD_TYPE=Release \ -DCMAKE_BUILD_TYPE=Release \
-DLLVM_ENABLE_ASSERTIONS=ON \ -DLLVM_ENABLE_ASSERTIONS=ON \
-DLLVM_ENABLE_RTTI=ON -DLLVM_ENABLE_RTTI=ON; \
fi
# Build for 30 minutes:
RUN timeout 30m cmake --build . --target -- ${MAKEFLAGS} || true
RUN cmake --build . --target -- ${MAKEFLAGS}
# RUN cmake --build . --target check-mlir # RUN cmake --build . --target check-mlir

View File

@ -20,7 +20,7 @@ Firstly, install MLIR (as a part of LLVM-Project):
``` bash ``` bash
git clone https://github.com/llvm/llvm-project.git git clone https://github.com/llvm/llvm-project.git
# Check out a specific branch that is known to work with ONNX MLIR. # Check out a specific branch that is known to work with ONNX MLIR.
cd llvm-project && git checkout 9c94908320549a1a2328c758d6bbb694466021e7 && cd .. cd llvm-project && git checkout 1d01fc100bb5bef5f5eaf92520b2e52f64ee1d6e && cd ..
``` ```
[same-as-file]: <> (utils/build-mlir.sh) [same-as-file]: <> (utils/build-mlir.sh)
@ -110,7 +110,7 @@ Install MLIR (as a part of LLVM-Project):
```shell ```shell
git clone https://github.com/llvm/llvm-project.git git clone https://github.com/llvm/llvm-project.git
# Check out a specific branch that is known to work with ONNX MLIR. # Check out a specific branch that is known to work with ONNX MLIR.
cd llvm-project && git checkout 9c94908320549a1a2328c758d6bbb694466021e7 && cd .. cd llvm-project && git checkout 1d01fc100bb5bef5f5eaf92520b2e52f64ee1d6e && cd ..
``` ```
[same-as-file]: <> (utils/build-mlir.cmd) [same-as-file]: <> (utils/build-mlir.cmd)

View File

@ -309,14 +309,15 @@ std::vector<Value> getLoopIVsForBroadcasting(Location loc,
Value emitConstantOp( Value emitConstantOp(
PatternRewriter &rewriter, Location loc, Type type, double value) { PatternRewriter &rewriter, Location loc, Type type, double value) {
Attribute constantAttr; Attribute constantAttr;
auto typeKind = type.getKind();
if (typeKind == StandardTypes::F16) { TypeSwitch<Type>(type)
constantAttr = rewriter.getF16FloatAttr((float)value); .Case<Float16Type>(
} else if (typeKind == StandardTypes::F32) { [&](Type) { constantAttr = rewriter.getF16FloatAttr((float)value); })
constantAttr = rewriter.getF32FloatAttr((float)value); .Case<Float32Type>(
} else if (typeKind == StandardTypes::F64) { [&](Type) { constantAttr = rewriter.getF32FloatAttr((float)value); })
constantAttr = rewriter.getF64FloatAttr(value); .Case<Float64Type>(
} else if (typeKind == StandardTypes::Integer) { [&](Type) { constantAttr = rewriter.getF64FloatAttr((float)value); })
.Case<IntegerType>([&](Type) {
auto width = type.cast<IntegerType>().getWidth(); auto width = type.cast<IntegerType>().getWidth();
if (width == 1) { if (width == 1) {
constantAttr = rewriter.getBoolAttr(false); constantAttr = rewriter.getBoolAttr(false);
@ -324,40 +325,43 @@ Value emitConstantOp(
constantAttr = constantAttr =
rewriter.getIntegerAttr(type, APInt(width, (int64_t)value)); rewriter.getIntegerAttr(type, APInt(width, (int64_t)value));
} }
} else if (typeKind == StandardTypes::Index) { })
.Case<IndexType>([&](Type) {
constantAttr = rewriter.getIntegerAttr(type, (int64_t)value); constantAttr = rewriter.getIntegerAttr(type, (int64_t)value);
} else { })
llvm_unreachable("unsupported element type"); .Default([](Type) { llvm_unreachable("unsupported element type"); });
}
return rewriter.create<ConstantOp>(loc, constantAttr); return rewriter.create<ConstantOp>(loc, constantAttr);
} }
Value emitPositiveInfinityConstantOp( Value emitPositiveInfinityConstantOp(
ConversionPatternRewriter &rewriter, Location loc, Type type) { ConversionPatternRewriter &rewriter, Location loc, Type type) {
Attribute constantAttr; Attribute constantAttr;
auto typeKind = type.getKind();
if (typeKind == StandardTypes::F16) { TypeSwitch<Type>(type)
.Case<Float16Type>([&](Type) {
// 0x7C00 // 0x7C00
float value = std::numeric_limits<float>::infinity(); float value = std::numeric_limits<float>::infinity();
constantAttr = rewriter.getF16FloatAttr(value); constantAttr = rewriter.getF16FloatAttr(value);
} else if (typeKind == StandardTypes::F32) { })
.Case<Float32Type>([&](Type) {
// 0x7F800000 // 0x7F800000
float value = std::numeric_limits<float>::infinity(); float value = std::numeric_limits<float>::infinity();
constantAttr = rewriter.getF32FloatAttr(value); constantAttr = rewriter.getF32FloatAttr(value);
} else if (typeKind == StandardTypes::F64) { })
.Case<Float64Type>([&](Type) {
// 0x7FF0000000000000 // 0x7FF0000000000000
double value = std::numeric_limits<double>::infinity(); double value = std::numeric_limits<double>::infinity();
constantAttr = rewriter.getF64FloatAttr(value); constantAttr = rewriter.getF64FloatAttr(value);
} else if (typeKind == StandardTypes::Integer) { })
.Case<IntegerType>([&](Type) {
auto width = type.cast<IntegerType>().getWidth(); auto width = type.cast<IntegerType>().getWidth();
// The latest llvm-project includes a patch which allows getting the sign of // The latest llvm-project includes a patch which allows getting the
// IntegerType: // sign of IntegerType:
// https://github.com/llvm/llvm-project/commit/35b685270b410f6a1351c2a527021f22330c25b9 // https://github.com/llvm/llvm-project/commit/35b685270b410f6a1351c2a527021f22330c25b9
// as follows: // as follows:
// auto isSigned = type.cast<IntegerType>().isSigned(); // auto isSigned = type.cast<IntegerType>().isSigned();
// TODO (tungld): update the following statement once our llvm-project is // TODO (tungld): update the following statement once our llvm-project
// upgraded to include the patch. // is upgraded to include the patch.
auto isSigned = true; auto isSigned = true;
if (width == 8) { if (width == 8) {
if (isSigned) { if (isSigned) {
@ -394,38 +398,40 @@ Value emitPositiveInfinityConstantOp(
} else { } else {
llvm_unreachable("unsupported element type"); llvm_unreachable("unsupported element type");
} }
} else { })
llvm_unreachable("unsupported element type"); .Default([](Type) { llvm_unreachable("unsupported element type"); });
}
return rewriter.create<ConstantOp>(loc, constantAttr); return rewriter.create<ConstantOp>(loc, constantAttr);
} }
Value emitNegativeInfinityConstantOp( Value emitNegativeInfinityConstantOp(
ConversionPatternRewriter &rewriter, Location loc, Type type) { ConversionPatternRewriter &rewriter, Location loc, Type type) {
Attribute constantAttr; Attribute constantAttr;
auto typeKind = type.getKind();
if (typeKind == StandardTypes::F16) { TypeSwitch<Type>(type)
.Case<Float16Type>([&](Type) {
// 0xFC00 // 0xFC00
float value = -std::numeric_limits<float>::infinity(); float value = -std::numeric_limits<float>::infinity();
constantAttr = rewriter.getF16FloatAttr(value); constantAttr = rewriter.getF16FloatAttr(value);
} else if (typeKind == StandardTypes::F32) { })
.Case<Float32Type>([&](Type) {
// 0xFF800000 // 0xFF800000
float value = -std::numeric_limits<float>::infinity(); float value = -std::numeric_limits<float>::infinity();
constantAttr = rewriter.getF32FloatAttr(value); constantAttr = rewriter.getF32FloatAttr(value);
} else if (typeKind == StandardTypes::F64) { })
.Case<Float64Type>([&](Type) {
// 0xFFF0000000000000 // 0xFFF0000000000000
double value = -std::numeric_limits<double>::infinity(); double value = -std::numeric_limits<double>::infinity();
constantAttr = rewriter.getF64FloatAttr(value); constantAttr = rewriter.getF64FloatAttr(value);
} else if (typeKind == StandardTypes::Integer) { })
.Case<IntegerType>([&](Type) {
auto width = type.cast<IntegerType>().getWidth(); auto width = type.cast<IntegerType>().getWidth();
// The latest llvm-project includes a patch which allows getting the sign of // The latest llvm-project includes a patch which allows getting the
// IntegerType: // sign of IntegerType:
// https://github.com/llvm/llvm-project/commit/35b685270b410f6a1351c2a527021f22330c25b9 // https://github.com/llvm/llvm-project/commit/35b685270b410f6a1351c2a527021f22330c25b9
// as follows: // as follows:
// auto isSigned = type.cast<IntegerType>().isSigned(); // auto isSigned = type.cast<IntegerType>().isSigned();
// TODO (tungld): update the following statement once our llvm-project is // TODO (tungld): update the following statement once our llvm-project
// upgraded to include the patch. // is upgraded to include the patch.
auto isSigned = true; auto isSigned = true;
if (width == 8) { if (width == 8) {
if (isSigned) { if (isSigned) {
@ -462,9 +468,8 @@ Value emitNegativeInfinityConstantOp(
} else { } else {
llvm_unreachable("unsupported element type"); llvm_unreachable("unsupported element type");
} }
} else { })
llvm_unreachable("unsupported element type"); .Default([](Type) { llvm_unreachable("unsupported element type"); });
}
return rewriter.create<ConstantOp>(loc, constantAttr); return rewriter.create<ConstantOp>(loc, constantAttr);
} }

View File

@ -20,6 +20,7 @@
#include "mlir/Transforms/DialectConversion.h" #include "mlir/Transforms/DialectConversion.h"
#include "llvm/ADT/ArrayRef.h" #include "llvm/ADT/ArrayRef.h"
#include "llvm/ADT/Sequence.h" #include "llvm/ADT/Sequence.h"
#include "llvm/ADT/TypeSwitch.h"
#include "src/Dialect/Krnl/KrnlHelper.hpp" #include "src/Dialect/Krnl/KrnlHelper.hpp"
#include "src/Dialect/Krnl/KrnlOps.hpp" #include "src/Dialect/Krnl/KrnlOps.hpp"

View File

@ -34,7 +34,7 @@ using namespace mlir;
namespace mlir { namespace mlir {
KrnlOpsDialect::KrnlOpsDialect(MLIRContext *context) KrnlOpsDialect::KrnlOpsDialect(MLIRContext *context)
: Dialect(getDialectNamespace(), context) { : Dialect(getDialectNamespace(), context, TypeID::get<KrnlOpsDialect>()) {
addOperations< addOperations<
#define GET_OP_LIST #define GET_OP_LIST
#include "src/Dialect/Krnl/KrnlOps.cpp.inc" #include "src/Dialect/Krnl/KrnlOps.cpp.inc"

View File

@ -17,6 +17,7 @@
#include "mlir/IR/Function.h" #include "mlir/IR/Function.h"
#include "mlir/IR/OpDefinition.h" #include "mlir/IR/OpDefinition.h"
#include "mlir/IR/StandardTypes.h" #include "mlir/IR/StandardTypes.h"
#include "llvm/ADT/TypeSwitch.h"
#include "KrnlHelper.hpp" #include "KrnlHelper.hpp"
#include "KrnlTypes.hpp" #include "KrnlTypes.hpp"
@ -38,11 +39,10 @@ public:
/// Print a type registered to this dialect. /// Print a type registered to this dialect.
void printType(Type type, DialectAsmPrinter &os) const override { void printType(Type type, DialectAsmPrinter &os) const override {
switch (type.getKind()) { TypeSwitch<Type>(type).Case<LoopType>([&](Type) {
case KrnlTypes::Loop:
os << "loop"; os << "loop";
return; return;
} });
} }
}; };

View File

@ -13,16 +13,6 @@
#include <mlir/IR/Types.h> #include <mlir/IR/Types.h>
namespace mlir { namespace mlir {
namespace KrnlTypes {
enum Kinds {
// A krnl.loop is simply a reference to a for loop and will be used to:
// - Indicate the presence of a for loop in krnl.iterate.
// - Identify the loop in optimization intrinsics.
Loop = mlir::Type::Kind::FIRST_PRIVATE_EXPERIMENTAL_0_TYPE,
};
}
class LoopType class LoopType
: public mlir::Type::TypeBase<LoopType, mlir::Type, mlir::TypeStorage> { : public mlir::Type::TypeBase<LoopType, mlir::Type, mlir::TypeStorage> {
@ -30,11 +20,8 @@ public:
using Base::Base; using Base::Base;
// Support type inquiry through isa, cast and dyn_cast. // Support type inquiry through isa, cast and dyn_cast.
static bool kindof(unsigned kind) { return kind == KrnlTypes::Loop; }
// Get a unique instance of Loop type. // Get a unique instance of Loop type.
static LoopType get(mlir::MLIRContext *context) { static LoopType get(mlir::MLIRContext *context) { return Base::get(context); }
return Base::get(context, KrnlTypes::Loop);
}
}; };
} // namespace mlir } // namespace mlir

View File

@ -478,7 +478,7 @@ static void insertConvTransposeSpatialDim(SmallVectorImpl<int64_t> &outputDims,
/// Dialect creation, the instance will be owned by the context. This is the /// Dialect creation, the instance will be owned by the context. This is the
/// point of registration of custom types and operations for the dialect. /// point of registration of custom types and operations for the dialect.
ONNXOpsDialect::ONNXOpsDialect(mlir::MLIRContext *ctx) ONNXOpsDialect::ONNXOpsDialect(mlir::MLIRContext *ctx)
: mlir::Dialect(getDialectNamespace(), ctx) { : mlir::Dialect(getDialectNamespace(), ctx, TypeID::get<ONNXOpsDialect>()) {
addOperations< addOperations<
#define GET_OP_LIST #define GET_OP_LIST
#include "src/Dialect/ONNX/ONNXOps.cpp.inc" #include "src/Dialect/ONNX/ONNXOps.cpp.inc"
@ -2885,7 +2885,7 @@ struct SeqTypeStorage : public mlir::TypeStorage {
SeqType SeqType::get(llvm::ArrayRef<mlir::Type> elementTypes) { SeqType SeqType::get(llvm::ArrayRef<mlir::Type> elementTypes) {
assert(!elementTypes.empty() && "expected non-empty seq"); assert(!elementTypes.empty() && "expected non-empty seq");
mlir::MLIRContext *ctx = elementTypes.front().getContext(); mlir::MLIRContext *ctx = elementTypes.front().getContext();
return Base::get(ctx, ONNXTypes::SEQ, elementTypes); return Base::get(ctx, elementTypes);
} }
llvm::ArrayRef<mlir::Type> SeqType::getElementTypes() { llvm::ArrayRef<mlir::Type> SeqType::getElementTypes() {

View File

@ -54,30 +54,12 @@ public:
// Or we need two namespace? // Or we need two namespace?
// Will put all the ONNXOps into this namespace // Will put all the ONNXOps into this namespace
namespace onnxmlir { namespace onnxmlir {
namespace ONNXTypes {
enum Kind {
FIRST_USED_ONNX_TYPE = Type::FIRST_PRIVATE_EXPERIMENTAL_1_TYPE,
//#define HANDLE_TF_TYPE(tftype, enumerant, name) enumerant,
//#include "src/Dialect/ONNX/ONXTypes.def"
STRING,
SEQ,
LAST_USED_ONNX_TYPE,
};
} // namespace ONNXTypes
class StringType class StringType
: public mlir::Type::TypeBase<StringType, mlir::Type, mlir::TypeStorage> { : public mlir::Type::TypeBase<StringType, mlir::Type, mlir::TypeStorage> {
public: public:
using Base::Base; using Base::Base;
static bool kindof(unsigned kind) { return kind == ONNXTypes::STRING; }
static unsigned getTypeKind() { return ONNXTypes::STRING; } static StringType get(MLIRContext *ctx) { return Base::get(ctx); }
static StringType get(MLIRContext *ctx) {
return Base::get(ctx, ONNXTypes::STRING);
}
}; };
namespace detail { namespace detail {
@ -88,9 +70,6 @@ class SeqType
: public mlir::Type::TypeBase<SeqType, mlir::Type, detail::SeqTypeStorage> { : public mlir::Type::TypeBase<SeqType, mlir::Type, detail::SeqTypeStorage> {
public: public:
using Base::Base; using Base::Base;
static bool kindof(unsigned kind) { return kind == ONNXTypes::SEQ; }
static unsigned getTypeKind() { return ONNXTypes::SEQ; }
static SeqType get(llvm::ArrayRef<mlir::Type> elementTypes); static SeqType get(llvm::ArrayRef<mlir::Type> elementTypes);

View File

@ -376,14 +376,15 @@ void compileModuleToJniJar(
genJniJar(module, modelSharedLibPath, modelJniJarPath); genJniJar(module, modelSharedLibPath, modelJniJarPath);
} }
void registerDialects() { void registerDialects(mlir::MLIRContext &context) {
mlir::registerDialect<mlir::AffineDialect>(); // Load our Dialect in this MLIR Context.
mlir::registerDialect<mlir::LLVM::LLVMDialect>(); context.getOrLoadDialect<mlir::AffineDialect>();
mlir::registerDialect<mlir::scf::SCFDialect>(); context.getOrLoadDialect<mlir::LLVM::LLVMDialect>();
mlir::registerDialect<mlir::StandardOpsDialect>(); context.getOrLoadDialect<mlir::scf::SCFDialect>();
mlir::registerDialect<mlir::shape::ShapeDialect>(); context.getOrLoadDialect<mlir::StandardOpsDialect>();
mlir::registerDialect<mlir::ONNXOpsDialect>(); context.getOrLoadDialect<mlir::shape::ShapeDialect>();
mlir::registerDialect<mlir::KrnlOpsDialect>(); context.getOrLoadDialect<mlir::ONNXOpsDialect>();
context.getOrLoadDialect<mlir::KrnlOpsDialect>();
} }
void addONNXToMLIRPasses(mlir::PassManager &pm) { void addONNXToMLIRPasses(mlir::PassManager &pm) {

View File

@ -59,7 +59,7 @@ void compileModuleToSharedLibrary(
void compileModuleToJniJar( void compileModuleToJniJar(
const mlir::OwningModuleRef &module, std::string outputBaseName); const mlir::OwningModuleRef &module, std::string outputBaseName);
void registerDialects(); void registerDialects(mlir::MLIRContext &context);
void addONNXToMLIRPasses(mlir::PassManager &pm); void addONNXToMLIRPasses(mlir::PassManager &pm);

View File

@ -60,13 +60,14 @@ static llvm::cl::opt<bool> allowUnregisteredDialects(
llvm::cl::init(false)); llvm::cl::init(false));
int main(int argc, char **argv) { int main(int argc, char **argv) {
mlir::registerDialect<mlir::linalg::LinalgDialect>(); mlir::DialectRegistry registry;
mlir::registerDialect<mlir::AffineDialect>(); registry.insert<mlir::linalg::LinalgDialect>();
mlir::registerDialect<mlir::LLVM::LLVMDialect>(); registry.insert<mlir::AffineDialect>();
mlir::registerDialect<mlir::scf::SCFDialect>(); registry.insert<mlir::LLVM::LLVMDialect>();
mlir::registerDialect<mlir::StandardOpsDialect>(); registry.insert<mlir::scf::SCFDialect>();
mlir::registerDialect<mlir::vector::VectorDialect>(); registry.insert<mlir::StandardOpsDialect>();
mlir::registerDialect<mlir::shape::ShapeDialect>(); registry.insert<mlir::vector::VectorDialect>();
registry.insert<mlir::shape::ShapeDialect>();
registerTransformsPasses(); registerTransformsPasses();
registerAffinePasses(); registerAffinePasses();
@ -97,7 +98,8 @@ int main(int argc, char **argv) {
auto output = mlir::openOutputFile(output_filename, &error_message); auto output = mlir::openOutputFile(output_filename, &error_message);
assert(output); assert(output);
// TODO(imaihal): Change preloadDialectsInContext to false.
return failed(mlir::MlirOptMain(output->os(), std::move(file), passPipeline, return failed(mlir::MlirOptMain(output->os(), std::move(file), passPipeline,
split_input_file, verify_diagnostics, verify_passes, registry, split_input_file, verify_diagnostics, verify_passes,
allowUnregisteredDialects)); allowUnregisteredDialects, /*preloadDialectsInContext*/ true));
} }

View File

@ -13,7 +13,8 @@ using namespace onnx_mlir;
int main(int argc, char *argv[]) { int main(int argc, char *argv[]) {
setExecPath(argv[0], (void *)main); setExecPath(argv[0], (void *)main);
registerDialects(); mlir::MLIRContext context;
registerDialects(context);
llvm::cl::OptionCategory OnnxMlirOptions( llvm::cl::OptionCategory OnnxMlirOptions(
"ONNX MLIR Options", "These are frontend options."); "ONNX MLIR Options", "These are frontend options.");
@ -43,7 +44,6 @@ int main(int argc, char *argv[]) {
llvm::cl::ParseCommandLineOptions( llvm::cl::ParseCommandLineOptions(
argc, argv, "ONNX MLIR modular optimizer driver\n"); argc, argv, "ONNX MLIR modular optimizer driver\n");
mlir::MLIRContext context;
mlir::OwningModuleRef module; mlir::OwningModuleRef module;
processInputFile(inputFilename, emissionTarget, context, module); processInputFile(inputFilename, emissionTarget, context, module);

View File

@ -23,8 +23,8 @@ using namespace std;
bool isOMConvTheSameAsNaiveImplFor(const int N, const int C, const int H, bool isOMConvTheSameAsNaiveImplFor(const int N, const int C, const int H,
const int W, const int kH, const int kW, const int pHBegin, const int pHEnd, const int W, const int kH, const int kW, const int pHBegin, const int pHEnd,
const int pWBegin, const int pWEnd) { const int pWBegin, const int pWEnd) {
registerDialects();
MLIRContext ctx; MLIRContext ctx;
registerDialects(ctx);
auto module = ModuleOp::create(UnknownLoc::get(&ctx)); auto module = ModuleOp::create(UnknownLoc::get(&ctx));
OpBuilder builder(&ctx); OpBuilder builder(&ctx);

View File

@ -1,3 +1,3 @@
git clone https://github.com/llvm/llvm-project.git git clone https://github.com/llvm/llvm-project.git
# Check out a specific branch that is known to work with ONNX MLIR. # Check out a specific branch that is known to work with ONNX MLIR.
cd llvm-project && git checkout 9c94908320549a1a2328c758d6bbb694466021e7 && cd .. cd llvm-project && git checkout 1d01fc100bb5bef5f5eaf92520b2e52f64ee1d6e && cd ..