2019-10-28 23:10:24 +08:00
|
|
|
#!/bin/bash
|
|
|
|
|
2019-11-26 10:21:27 +08:00
|
|
|
# Exit on error:
|
|
|
|
set -e
|
|
|
|
|
2019-10-28 23:10:24 +08:00
|
|
|
# Check for required env variables JAVA_HOME
|
|
|
|
if [[ -z "${JAVA_HOME}" ]]; then
|
|
|
|
echo "JAVA_HOME env var is missing."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-11-26 10:21:27 +08:00
|
|
|
if [[ -z "${LLVM_PROJECT_ROOT}" ]]; then
|
|
|
|
echo "LLVM_PROJECT_ROOT env var is missing."
|
|
|
|
exit 1
|
|
|
|
fi
|
|
|
|
|
2019-10-28 23:10:24 +08:00
|
|
|
# Set up mock installation path:
|
2020-05-07 00:11:04 +08:00
|
|
|
export INSTALL_PATH=${WORKSPACE}/INSTALL_PATH
|
|
|
|
mkdir -p ${INSTALL_PATH}
|
|
|
|
export PATH=${INSTALL_PATH}/bin:${PATH}
|
|
|
|
export LD_LIBRARY_PATH=${INSTALL_PATH}/lib:${INSTALL_PATH}/lib64:${LD_LIBRARY_PATH}
|
|
|
|
export CPATH=${INSTALL_PATH}/include:${CPATH}
|
2019-10-28 23:10:24 +08:00
|
|
|
|
|
|
|
# Set up project specific environment variables:
|
2020-05-07 00:11:04 +08:00
|
|
|
export PATH=${JAVA_HOME}/bin:${PATH}
|
|
|
|
export CLASSPATH=.:${JAVA_HOME}/lib:${JAVA_HOME}/lib/tools.jar:${CLASSPATH}
|
|
|
|
|
2020-05-20 11:39:37 +08:00
|
|
|
# If LLVM_PROJECT_ROOT does not exist, or llvm-project commit hash changed,
|
|
|
|
# (re)build llvm-project
|
|
|
|
if ! [ -d ${LLVM_PROJECT_ROOT} ]; then
|
|
|
|
git clone https://github.com/llvm/llvm-project.git ${LLVM_PROJECT_ROOT}
|
|
|
|
fi
|
|
|
|
PREBUILT_LLVM_PROJECT_SHA1=$(git -C ${LLVM_PROJECT_ROOT} rev-parse HEAD)
|
|
|
|
EXPECTED_LLVM_PROJECT_SHA1=$(cat utils/clone-mlir.sh|grep -Po '(?<=git checkout )[0-9a-f]+')
|
|
|
|
|
|
|
|
echo "${LLVM_PROJECT_ROOT} sha1 prebuilt ${PREBUILT_LLVM_PROJECT_SHA1} expected ${EXPECTED_LLVM_PROJECT_SHA1}"
|
|
|
|
|
|
|
|
if [ "$1" = "shared" ]; then
|
|
|
|
LLVM_BUILD_SHARED_LIBS=ON
|
|
|
|
else
|
|
|
|
LLVM_BUILD_SHARED_LIBS=OFF
|
|
|
|
fi
|
|
|
|
|
|
|
|
if ! [ -d ${LLVM_PROJECT_ROOT}/build ] ||
|
|
|
|
[ "${PREBUILT_LLVM_PROJECT_SHA1}" != "${EXPECTED_LLVM_PROJECT_SHA1}" ]; then
|
|
|
|
echo "Rebuild llvm-project with sha1 ${EXPECTED_LLVM_PROJECT_SHA1}"
|
|
|
|
pushd ${LLVM_PROJECT_ROOT}
|
|
|
|
git fetch && git checkout ${EXPECTED_LLVM_PROJECT_SHA1}
|
|
|
|
rm -rf build && mkdir -p build && cd build
|
|
|
|
cmake -G Ninja ../llvm \
|
|
|
|
-DLLVM_ENABLE_PROJECTS=mlir \
|
|
|
|
-DLLVM_BUILD_EXAMPLES=ON \
|
|
|
|
-DLLVM_TARGETS_TO_BUILD="host" \
|
|
|
|
-DCMAKE_BUILD_TYPE=Release \
|
|
|
|
-DLLVM_ENABLE_ASSERTIONS=ON \
|
|
|
|
-DLLVM_ENABLE_RTTI=ON \
|
|
|
|
-DBUILD_SHARED_LIBS=${LLVM_BUILD_SHARED_LIBS}
|
|
|
|
cmake --build . --target -- ${MAKEFLAGS}
|
|
|
|
popd
|
|
|
|
else
|
|
|
|
echo "Rebuild llvm-project not needed"
|
|
|
|
fi
|
|
|
|
|
|
|
|
# Build ONNX MLIR against specified llvm-project
|
2020-05-07 00:11:04 +08:00
|
|
|
export BUILD_PATH=build-against-$(basename ${LLVM_PROJECT_ROOT})
|
|
|
|
mkdir ${BUILD_PATH} && cd ${BUILD_PATH}
|
|
|
|
|
|
|
|
LLVM_PROJ_SRC=${LLVM_PROJECT_ROOT} \
|
|
|
|
LLVM_PROJ_BUILD=${LLVM_PROJECT_ROOT}/build \
|
|
|
|
cmake -DCMAKE_INSTALL_PREFIX=${INSTALL_PATH} .. \
|
|
|
|
|
|
|
|
make -j$(nproc) onnx-mlir
|
|
|
|
make -j$(nproc) check-onnx-lit
|
Compiling Models with Large Constant Arrays (#146)
* PoC works.
* MNist works.
* Clean up.
* Fix test.
* Make Linux work.
* Use consistent symbol name.
* Fix variable name.
* Fix array addr access.
* Bug fix.
* Bug fix.
* install before running e2e tests.
* Fix build config.
* Use sudo when installing.
* Make embeddedDataLoader position independent.
* Enable ResNet50.
* Format code.
* Format MainUtil.
* Try not using sudo to install.
* Supply runtime dir via environment variable.
* Dump problematic operation.
* Dump entire function.
* Debug.
* Dump input.
* Dump constant op.
* Debug.
* Debug.
* Debug.
* Print to stderr.
* take care of endianness.
* Use endianness-aware execution session.
* Fix ZLinux error.
* Include warning when desired output endianness can't be deduced.
* Remove debug code.
* Remove debug code in shape inference.
* Support binary-decoder for testing constants packing.
* Support filename, move-to-file, elision-threshold configurations in constant packing pass for easy testing.
* Add lit test, fix lit test type mismatch.
* Add more consts packing tests.
* Ensure intermediate files are properly cleaned up.
* No need for constant elimination.
* Link with threading libraries.
* Remove debug code.
* Format code.
* More tests.
* test nit.
* Remove debug code.
* Reduce hard-coded constants.
* Use temporary and unique working directory for hosting model parameters.
* Test if it works.
* Try to find objcopy.
* Rename symbols using objcopy.
* Move sanitized name to linux section.
* Use verbose mode for debugging.
* Disambiguate pass constructor.
* Fix symbol name.
* Use Command API to build and execute commands.
* Move linux to use Command API.
* Fix reset args.
* Execute redefine sym.
* Format code.
* Do not use verbose mode for CircleCI.
* Remove debug code.
* Prettify code, add comments.
* getSegmentData -> getEmbeddedConstPool
* vector -> std::vector.
* Make sure we properly clean up intermediate files.
* Fix test cases.
* Add runtime directory.
* Trigger rebuild.
* [Merge with master] fix debug script.
* Diable affine fusion pass for now.
* Support generic fallback const packing mechanism.
* Remove debug code.
* Handle the case where objcopy is not available.
* Fix Windows missing types.
* Support int64.
* Copy packed constant to a local directory for non-Linux/Mac platforms.
* Nit: remove debug code, refactor const pack preprocessing out as a separate function.
* Cannot make preprocessConstPack a standalone function because file removers are stack-allocated, and they are deallocated prematurely when function stack gets popped, deleteing intermediate files too early.
* Don't require executable filename.
* Import ONNX data types directly.
* Fix LIT test.
* Bug fix, use moved string value.
* Remove redundant filenames.
* Fix CMake script.
* Embed endianness information as a symbol, and check during runtime.
* More comments, update lit tests.
* Fix lit test on BE machine.
* Copyright notices.
2020-06-12 10:27:05 +08:00
|
|
|
RUNTIME_DIR=$(pwd)/lib make -j$(nproc) check-onnx-backend
|