onnx / onnx-mlir

Representation and Reference Lowering of ONNX Models in MLIR Compiler Infrastructure
Apache License 2.0
746 stars 315 forks source link

A stable onnx-mlir version for LLVM 16.0.6 #2483

Closed MisGreee closed 1 year ago

MisGreee commented 1 year ago

I'm in the process of developing my own AI compiler, leveraging LLVM version 16.0.6. I've attempted to build onnx-mlir versions 0.4.1 and 0.3.2, but I've encountered issues with both. Is there a stable version available for it?

my build command:

cmake -G Ninja -DCMAKE_C_COMPILER=clang-16 -DCMAKE_CXX_COMPILER=clang++-16 -DLLVM_ROOT=/usr/local/llvm -DMLIR_DIR=/usr/local/llvm/lib/cmake/mlir/ ..

part of error while building it: building onnx-mlir v0.3.2: [18/417] Building KrnlDialect.cpp.inc... FAILED: src/Dialect/Krnl/KrnlDialect.cpp.inc /home/asuka/saito/onnx-mlir/build/src/Dialect/Krnl/KrnlDialect.cpp.inc cd /home/asuka/saito/onnx-mlir/build && /usr/local/llvm/bin/mlir-tblgen -gen-dialect-defs -dialect=krnl -I/home/asuka/saito/onnx-mlir -I /home/asuka/saito/onnx-mlir/src/Dialect/Krnl -I/usr/local/llvm/include -I/usr/local/llvm/include /home/asuka/saito/onnx-mlir/src/Dialect/Krnl/Krnl.td --write-if-changed -o src/Dialect/Krnl/KrnlDialect.cpp.inc -d src/Dialect/Krnl/KrnlDialect.cpp.inc.d /home/asuka/saito/onnx-mlir/src/Dialect/Krnl/Krnl.td:33:28: error: Value 'emitAccessorPrefix' unknown! let emitAccessorPrefix = kEmitAccessorPrefix_Raw;

building onnx-mlir v0.4.1: onnx-mlir/src/Support/SmallFP.hpp:188:27: error: no member named 'Float8E4M3FNUZ' in 'llvm::APFloat'; did you mean 'Float8E4M3FN'? /home/asuka/saito/onnx-mlir/src/Dialect/ONNX/ElementsAttr/ElementsAttrBuilder.cpp:480:40: error: no member named 'getShapedType' in 'mlir::ElementsAttr' ArrayRef<int64_t> firstShape = first.getShapedType().getShape();

philass commented 1 year ago

onnx-mlir builds with specific commits of LLVM. It is unlikely you will get onnx-mlir to work without building LLVM from source and on a specific commit.

The instructions can be found here https://github.com/onnx/onnx-mlir/blob/main/docs/BuildOnLinuxOSX.md.

In short, the answer to your question is no.

MisGreee commented 1 year ago

onnx-mlir builds with specific commits of LLVM. It is unlikely you will get onnx-mlir to work without building LLVM from source and on a specific commit.

The instructions can be found here https://github.com/onnx/onnx-mlir/blob/main/docs/BuildOnLinuxOSX.md.

In short, the answer to your question is no.

thanks for your help. from what you mentioned, it seems challenging to compile onnx-mlir as a third-party library instead, it's better suited as a standalone binary.

philass commented 1 year ago

@MisGreee I think that is a fair assessment.

MLIR itself isn't very stable, which is a large part of why its hard to restrict ourself to a stable version. It would be too restrictive to development of the repo.

We do update LLVM every two weeks. You can see the schedule here https://github.com/onnx/onnx-mlir/wiki/LLVM-Update-Schedule. And the commit isn't totally random. We try and sync with the same commit that torch-mlir, and hlo use.

I know that doesn't help your situation. I just wanted to add some context in case you were curious.

The LLVM versioning is a nightmare that I think everybody suffers from, and deals with in the their own way unfortunately.

MisGreee commented 1 year ago

@MisGreee I think that is a fair assessment.

MLIR itself isn't very stable, which is a large part of why its hard to restrict ourself to a stable versions. It would be too restrictive to development of the repo.

We do update LLVM every two weeks. You can see the schedule here https://github.com/onnx/onnx-mlir/wiki/LLVM-Update-Schedule. And the commit isn't totally random. We try and sync with the same commit that torch-mlir, and hlo use.

I know that doesn't help your situation. I just wanted to add some context in case you were curious.

The LLVM versioning is a nightmare that I think everybody suffers from, and deals with in the their own way unfortunately.

outstanding and inspiring work 👍