stellaraccident / tpp-sandbox

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

TPP Sandbox

This is an experiment in using MLIR to automatically select the best Tensor Processing Primitives for ML models.

This repository contains an out-of-tree MLIR dialect as well as a standalone opt-like tool to operate on that dialect.

It also contains the recipes to use LIBXSMM from inside MLIR and can be used by other tools to drive our passes.

There's work in progress inside IREE to use this sandbox's work on their pipeline.

Build Status

Standalone build status

How to build LLVM

# Clone
https://github.com/llvm/llvm-project.git
mkdir llvm-project/build
pushd llvm-project/build

# This is important for the next step
export CUSTOM_LLVM_ROOT=`pwd`
echo $CUSTOM_LLVM_ROOT
export PATH=$CUSTOM_LLVM_ROOT/bin:$PATH

# Build
cmake -G Ninja ../llvm \
   -DLLVM_ENABLE_PROJECTS=mlir \
   -DLLVM_BUILD_EXAMPLES=ON \
   -DLLVM_INSTALL_UTILS=ON \
   -DLLVM_TARGETS_TO_BUILD="X86;NVPTX;AMDGPU" \
   -DCMAKE_BUILD_TYPE=RelWithDebInfo \
   -DLLVM_ENABLE_ASSERTIONS=ON \
   -DCMAKE_C_COMPILER=clang \
   -DCMAKE_CXX_COMPILER=clang++ \
   -DLLVM_USE_LINKER=lld
ninja 

popd

How to build

This setup assumes that you have built LLVM and MLIR in $CUSTOM_LLVM_ROOT as above.

# Clone
git clone https://github.com/plaidml/tpp-sandbox.git
mkdir tpp-sandbox/build
pushd tpp-sandbox/build

# Build & test
cmake -G Ninja .. \
   -DCMAKE_BUILD_TYPE=RelWithDebInfo \
   -DMLIR_DIR=$CUSTOM_LLVM_ROOT/lib/cmake/mlir \
   -DLLVM_EXTERNAL_LIT=$CUSTOM_LLVM_ROOT/bin/llvm-lit
cmake --build . --target check-standalone-opt

popd

To build the documentation from the TableGen description of the dialect operations, run:

cmake --build . --target mlir-doc

License

This dialect template is made available under the Apache License 2.0 with LLVM Exceptions. See the LICENSE.txt file for more details.

TODO:

  1. Align runtime with IREE see: https://github.com/iree-org/iree/tree/main/compiler/src/iree/compiler/Dialect/VMVX (You don't want to pass the memref to the runtime but the single pointer + offset + strides).

Note:

About

License:Other


Languages

Language:C++ 48.3%Language:MLIR 43.0%Language:C 3.9%Language:CMake 2.5%Language:Shell 1.4%Language:Python 0.5%Language:Makefile 0.4%