Browse Source

doc: add build-mlir2ncnn with commit sha and steps (#2706)

* doc: add build-mlir2ncnn with commit sha and steps

* add mlir git log detail
tags/20210322
Zhuo Zhang GitHub 5 years ago
parent
commit
06e40a75d7
No known key found for this signature in database GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 56 additions and 0 deletions
  1. +56
    -0
      docs/how-to-build/build-mlir2ncnn.md

+ 56
- 0
docs/how-to-build/build-mlir2ncnn.md View File

@@ -0,0 +1,56 @@
# mlir2ncnn

## Compile

**Clone LLVM**
```bash
https://github.com/llvm/llvm-project.git
git checkout -b mlir <a_working_commit_id>
```
Current working commit id is 7c15e0f64ccc79a53ed2db258f1cb58ec452a957:
```
$ git log

commit 7c15e0f64ccc79a53ed2db258f1cb58ec452a957 (HEAD -> 01-26)
Author: MaheshRavishankar <ravishankarm@google.com>
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=<path/to/your/llvm_install/lib/cmake/llvm>
make
```

## Usage

**Export `.mlir`**

See https://zhuanlan.zhihu.com/p/152535430


**Usage mlir2ncnn**

```
./mlir2ncnn pix2pix.mlir pix2pix.param pix2pix.bin
```

Loading…
Cancel
Save