Remove dimension specific typedefs (#45)

6 files changed
tree: 6331ba3320db05fcc6ccc6aca9ba3f89440a94bb
  1. .github/
  2. build_tools/
  3. docs/
  4. include/
  5. lib/
  6. scripts/
  7. test/
  8. third_party/
  9. tools/
  10. unittests/
  11. .clang-format
  12. .gitignore
  13. .gitmodules
  14. CMakeLists.txt
  15. LICENSE
  16. README.md
README.md

MLIR EmitC

Build and test

EmitC is a MLIR dialect to emit C++ code. The initial checked in code is forked from https://reviews.llvm.org/D76571.

DISCLAIMER: This is a research project and not intended for everyday use. The code is made available without any support. However, we welcome any kind of feedback via the issue tracker.

EmitC enables to convert operations from other MLIR dialects to EmitC ops and to translate those to C++.

Getting Started

Clone

git clone https://github.com/iml130/mlir-emitc.git
cd mlir-emitc
git submodule update --init

Build and Run

The setup assumes that you have built LLVM and MLIR in $BUILD_DIR and installed them to $PREFIX. You can use the build_tools/build_mlir.sh shell script to configure, build and install LLVM and MLIR.

Note: The hash of the latest tested LLVM version is given in build_tools/llvm_version.txt. Since MLIR evolves fast, it is possible that EmitC fails to build with a newer LLVM.

To build and launch the tests, run

mkdir build && cd build
cmake -G Ninja -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++ .. -DMLIR_DIR=$PREFIX/lib/cmake/mlir -DLLVM_EXTERNAL_LIT=$BUILD_DIR/bin/llvm-lit
cmake --build . --target check-emitc

Note: If you don't use build_tools/build_mlir.sh, make sure to pass -DLLVM_INSTALL_UTILS=ON when building LLVM with CMake in order to install FileCheck to the chosen installation prefix.

To additionally build and execute the unittests, run

cmake --build . --target MLIREmitCAllTests
./unittests/MLIREmitCAllTests

Supported Conversions and Translations

Conversions are supported for MLIR-HLO ops and some ops of the standard and SCF dialect. The emitc-opt tool enables conversions via the following options:

option
--convert-mhlo-region-ops-to-emitc Convert MHLO operations containing regions to EmitC dialect.
--convert-mhlo-to-emitc Convert from MHLO dialect to EmitC dialect.
--convert-scf-to-emitcConvert SCF dialect to EmitC dialect, replacing IfOp and ForOp.
--convert-std-to-emitc Convert std dialect to EmitC dialect, replacing IndexCastOp and SplatOp.
--convert-tensor-to-emitc Convert tensor dialect to EmitC dialect, replacing ExtractOp.

The currently supported MHLO ops are listed in the docs/mhlo-op-coverage.md document.

Furthermore, the emitc-opt tools supports the conversion from mhlo.constant to constant via --convert-mhlo-const-to-std . This conversion is necessary because EmitC does not implement a conversion from mhlo.constant, but does support constant in the translation to C++.

After converting to EmitC, C++ code can be emited using emitc-translate --mlir-to-cpp.