Skip to content

Latest commit

 

History

History
110 lines (86 loc) · 2.05 KB

Usage.md

File metadata and controls

110 lines (86 loc) · 2.05 KB

Usage

Prepare the environment

🌟 Use the docker image

  • Option 0: Get pre-built images from Docker Hub: zincnode/mlir-he. Execute the following to pull the image:
docker pull zincnode/mlir-he
  • Option 1: Build the docker image manually. Please refer to docker/README.

⭐ Build environment manually

  • Install dependencies
pip install numpy pybind11
  • Clone llvm-project
git clone https://github.com/llvm/llvm-project.git
  • Build and install llvm-project
mkdir llvm-project/build llvm-project/install && cd llvm-project/build

cmake -G Ninja ../llvm \
   -DLLVM_ENABLE_PROJECTS=mlir \
   -DLLVM_TARGETS_TO_BUILD="host" \
   -DCMAKE_BUILD_TYPE=Release \
   -DLLVM_ENABLE_ASSERTIONS=ON \
   -DCMAKE_C_COMPILER=clang \
   -DCMAKE_CXX_COMPILER=clang++ \
   -DLLVM_ENABLE_LLD=ON \
   -DMLIR_ENABLE_BINDINGS_PYTHON=ON \
   -DLLVM_INSTALL_UTILS=ON \
   -DLLVM_ENABLE_BINDINGS=OFF \
   -DCMAKE_INSTALL_PREFIX=../install

ninja install
  • Run tests
ninja check-mlir
  • Configure environment variables
export LLVM_BUILD_DIR=<llvm-project-path>/build
export LLVM_INSTALL_DIR=<llvm-project-path>/install

Build mlir-he

  • Clone mlir-he
git clone https://github.com/zincnode/mlir-he.git
  • Build
./scripts/build.sh
  • Build with Python bindings
./scripts/build.sh -pb

📝: The compiled Python package is named mlir_he and the path is <build_dir>/python_packages/mlir_he_core/.

  • Build in debug mode
./scripts/build.sh -d
  • Run tests
./scripts/build.sh -t # or ./scripts/build.sh -pb -t

or

  • Build
mkdir mlir-he/build && cd mlir-he/build
cmake -G Ninja .. \
   -DMLIR_DIR=$LLVM_INSTALL_DIR/lib/cmake/mlir \
   -DLLVM_EXTERNAL_LIT=$LLVM_BUILD_DIR/bin/llvm-lit \
   -DCMAKE_C_COMPILER=clang \
   -DCMAKE_CXX_COMPILER=clang++ \
   -DCMAKE_BUILD_TYPE="Release" \ # or "Debug"
   -DMLIR_HE_ENABLE_BINDINGS_PYTHON=OFF # or ON
ninja
  • Run tests
ninja check-mlir-he