Go to file
Tian Jin 51b0f4c9dd
Chentong319 attribute with variant (#25)
* change the read-in of attribute, using variant

* Use backported variant.

* Reduce code duplication.

* 1. Make array attribute parsing more clear.
2. int -> int64_t.

* 1. Fix how array attributes are imported.

* 1. Fix clang-tidy warnings.

* 1. Nit: fix clang-tidy warnings.

* Fix MaxPool node construction.

* Fix call to MaxPool.

* Comment out backend tests that fail.

* Add path to variant submodule to enable include file detection.

* Allow unused argument to avoid special casing generator.

* Address attribute related e2e test failures for Hard sigmoid,Elu,LeakyRelu,Selu,Softmax

Co-authored-by: chentong319 <chentong@us.ibm.com>
Co-authored-by: Gheorghe-Teodor Bercea <gt.bercea@gmail.com>
2020-01-21 19:36:21 -07:00
.buildbot Exit Bash Script on Error (#381) 2019-12-21 00:50:30 -05:00
.circleci Enable e2e tests (#29) 2020-01-20 12:30:08 -05:00
doc Use a more compatible way to locate python interpreter executable. (#28) 2020-01-13 21:52:54 -05:00
src Chentong319 attribute with variant (#25) 2020-01-21 19:36:21 -07:00
test Chentong319 attribute with variant (#25) 2020-01-21 19:36:21 -07:00
third_party Chentong319 attribute with variant (#25) 2020-01-21 19:36:21 -07:00
utils Enable e2e tests (#29) 2020-01-20 12:30:08 -05:00
.clang-format clean up 2019-12-21 02:07:24 -05:00
.gitignore Initial commit 2019-12-18 10:18:14 -05:00
.gitmodules Chentong319 attribute with variant (#25) 2020-01-21 19:36:21 -07:00
CMakeLists.txt Chentong319 attribute with variant (#25) 2020-01-21 19:36:21 -07:00
LICENSE Initial commit 2019-12-18 10:18:14 -05:00
MLIR.cmake Update LLVM_SRC, LLVM_BUILD env vars to LLVM_PROJ_SRC, LLVM_PROJ_BUILD since MLIR is now parallel to LLVM in llvm-project repository. 2020-01-06 15:59:19 -05:00
README.md Enable e2e tests (#29) 2020-01-20 12:30:08 -05:00
SharingWork.md Lowering softmax (#14) 2020-01-20 21:57:32 -05:00

README.md

ONNF

Open Neural Network Frontend : an ONNX frontend for MLIR.

CircleCI

Installation

Firstly, install MLIR (as a part of LLVM-Project):

git clone https://github.com/llvm/llvm-project.git
mkdir llvm-project/build
cd llvm-project/build
cmake -G Ninja ../llvm \
   -DLLVM_ENABLE_PROJECTS=mlir \
   -DLLVM_BUILD_EXAMPLES=ON \
   -DLLVM_TARGETS_TO_BUILD="host" \
   -DCMAKE_BUILD_TYPE=Release \
   -DLLVM_ENABLE_ASSERTIONS=ON \
   -DLLVM_ENABLE_RTTI=ON

cmake --build . --target
cmake --build . --target check-mlir

Two environment variables need to be set:

  • LLVM_PROJ_SRC should point to the llvm-project src directory (e.g., llvm-project/).
  • LLVM_PROJ_BUILD should point to the llvm-project build directory (e.g., llvm-project/build).

To build ONNF, use the following command:

git clone --recursive git@github.com:clang-ykt/ONNF.git

# Export environment variables pointing to LLVM-Projects.
export LLVM_PROJ_SRC=$(pwd)/llvm-project/
export LLVM_PROJ_BUILD=$(pwd)/llvm-project/build

mkdir ONNF/build && cd ONNF/build
cmake ..
cmake --build . --target onnf

# Run FileCheck tests:
export LIT_OPTS=-v
cmake --build . --target check-mlir-lit

After the above commands succeed, an onnf executable should appear in the bin directory.

Using ONNF

The usage of onnf is as such:

OVERVIEW: ONNF MLIR modular optimizer driver

USAGE: onnf [options] <input file>

OPTIONS:

Generic Options:

  --help        - Display available options (--help-hidden for more)
  --help-list   - Display list of available options (--help-list-hidden for more)
  --version     - Display the version of this program

ONNF Options:
These are frontend options.

  Choose target to emit:
      --EmitONNXIR - Ingest ONNX and emit corresponding ONNX dialect.
      --EmitMLIR   - Lower model to MLIR built-in transformation dialect.
      --EmitLLVMIR - Lower model to LLVM IR (LLVM dialect).
      --EmitLLVMBC - Lower model to LLVM IR and emit (to file) LLVM bitcode for model.

Example

For example, to lower an ONNX model (e.g., add.onnx) to ONNX dialect, use the following command:

./onnf --EmitONNXIR add.onnx

The output should look like:

module {
  func @main_graph(%arg0: tensor<10x10x10xf32>, %arg1: tensor<10x10x10xf32>) -> tensor<10x10x10xf32> {
    %0 = "onnx.Add"(%arg0, %arg1) : (tensor<10x10x10xf32>, tensor<10x10x10xf32>) -> tensor<10x10x10xf32>
    return %0 : tensor<10x10x10xf32>
  }
}