commit | c0e1533d87eec6cbeadfa788c5cbc6e0c7c101db | [log] [tgz] |
---|---|---|
author | Simon Camphausen <simon.camphausen@iml.fraunhofer.de> | Thu Feb 04 09:33:48 2021 +0100 |
committer | GitHub <noreply@github.com> | Thu Feb 04 09:33:48 2021 +0100 |
tree | 6331ba3320db05fcc6ccc6aca9ba3f89440a94bb | |
parent | a952a2c68151666907e7c32d1cd13094c809e8c2 [diff] |
Remove dimension specific typedefs (#45)
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++.
git clone https://github.com/iml130/mlir-emitc.git cd mlir-emitc git submodule update --init
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
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-emitc | Convert 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
.