8000 GitHub - HadXu/flow-mlir: A simple MLIR Dialect, base on toy programming language.
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

HadXu/flow-mlir

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

48 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

A MLIR Demo Dialect - Flow Dialect (on LLVM(release/16.x))

关于MLIR 官方的toy例子就非常好,但是非常分散,在实际项目中需要有一个统一的文件组织进行MLIR编译器的开发,本项目基于toy进行修改,统一文件排序规范以及链接库的整理。

Flow Dialect Ops (todo GPU Support openai/triton)

  1. flow.constant ✅
  2. flow.func ✅
  3. flow.return ✅
  4. flow.transpose ✅
  5. flow.reshape ✅
  6. flow.add ✅
  7. flow.mul ✅
  8. flow.sub ✅
  9. flow.div ✅
  10. flow.print ✅ (支持各种print)
  11. flow.dot ✅
  12. flow.sum ✅ (1D)
  13. support math Dialect ✅
  14. matmul(linalg)
  15. conv1d(linalg)
  16. conv2d(linalg)
  17. sqrt ✅
  18. exp ✅
  19. pow ✅

1. flow dialect

flow.func @main() {
    %0 = flow.constant dense<[1.0, 2.0, 3.0, 4.0, 9.0, 32.0]> : tensor<6xf64>
    %2 = flow.sum %0: tensor<6xf64> to f64
    %3 = flow.dot %0, %0: tensor<6xf64>, tensor<6xf64> to f64
    %4 = math.atan %3: f64
    flow.print %4: f64
    flow.return
}

2. lowing to affine

3. lowing to llvm

4. run with jit

use

mlir::ExecutionEngineOptions engineOptions;
engineOptions.transformer = optPipeline;
engineOptions.sharedLibPaths = {"", ""};

lowing to llvm

将custom dialect lowering to vector dialect. (need to read vector lowering source file).

Usage

## 2023.04.25 update

use pre-built mlir && llvm library
https://github.com/ptillet/triton-llvm-releases

or build yourself.

git clone https://github.com/llvm/llvm-project.git
cd llvm-project && git checkout release/16.x && mkdir build && cd build
cmake -G Ninja ../llvm \
 -DLLVM_ENABLE_PROJECTS="mlir;clang" \
 -DLLVM_BUILD_EXAMPLES=ON \
 -DLLVM_TARGETS_TO_BUILD="host;RISCV;ARM;X86" \
 -DCMAKE_BUILD_TYPE=Release \
 -DLLVM_ENABLE_ASSERTIONS=ON \
 -DMLIR_ENABLE_BINDINGS_PYTHON=ON \
 -DLLVM_CCACHE_BUILD=ON \
 -DMLIR_ENABLE_BINDINGS_PYTHON=ON
 
# wait a coffe time.

cd flow-mlir && mkdir build
cmake .. # you should look CMakelists.txt to change your mlir build path
make

About

A simple MLIR Dialect, base on toy programming language.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published
0