From 06e40a75d751cefc23f0e2be836f1f379b1ae9c8 Mon Sep 17 00:00:00 2001 From: Zhuo Zhang Date: Wed, 24 Feb 2021 23:37:01 +0800 Subject: [PATCH] doc: add build-mlir2ncnn with commit sha and steps (#2706) * doc: add build-mlir2ncnn with commit sha and steps * add mlir git log detail --- docs/how-to-build/build-mlir2ncnn.md | 56 ++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 docs/how-to-build/build-mlir2ncnn.md diff --git a/docs/how-to-build/build-mlir2ncnn.md b/docs/how-to-build/build-mlir2ncnn.md new file mode 100644 index 000000000..cf375d3e5 --- /dev/null +++ b/docs/how-to-build/build-mlir2ncnn.md @@ -0,0 +1,56 @@ +# mlir2ncnn + +## Compile + +**Clone LLVM** +```bash +https://github.com/llvm/llvm-project.git +git checkout -b mlir +``` +Current working commit id is 7c15e0f64ccc79a53ed2db258f1cb58ec452a957: +``` +$ git log + +commit 7c15e0f64ccc79a53ed2db258f1cb58ec452a957 (HEAD -> 01-26) +Author: MaheshRavishankar +Date: Tue Jan 26 23:21:33 2021 -0800 + + [mlir][Linalg] Add canonicalization for init_tensor -> subtensor op. + + Differential Revision: https://reviews.llvm.org/D95305 +``` + +It is determined by query lastest git commit date of `tools/mlir` directory. + + +**Compile mlir** +```bash +cd llvm-project +mkdir build +cd build +cmake -G Ninja -DCMAKE_INSTALL_PREFIX=install -DCMAKE_BUILD_TYPE=Release -DBUILD_SHARED_LIBS=ON -DLLVM_ENABLE_PROJECTS="mlir" -DLLVM_TARGETS_TO_BUILD="" -DLLVM_INCLUDE_EXAMPLES=OFF -DLLVM_INCLUDE_TESTS=OFF ../llvm/ +make -j8 +make install +``` + +**Compile mlir2ncnn** +```bash +cd tools/mlir +mkdir build +cd build +cmake .. -D LLVM_DIR= +make +``` + +## Usage + +**Export `.mlir`** + +See https://zhuanlan.zhihu.com/p/152535430 + + +**Usage mlir2ncnn** + +``` +./mlir2ncnn pix2pix.mlir pix2pix.param pix2pix.bin +```