Skip to content

Commit

Permalink
Add instructions for building
Browse files Browse the repository at this point in the history
  • Loading branch information
daquexian committed Jun 9, 2019
1 parent 66dc6a9 commit c28e12c
Show file tree
Hide file tree
Showing 3 changed files with 63 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,12 @@ The following is the comparison between our dabnn and [Caffe](http://caffe.berke

![Comparison](images/comparison_en.png)

## Build

We provide pre-built onnx2bnn and also dabnn Android package. However, you need to build it if you want to deploy BNNs on non-Android ARM devices.

We use CMake build system like most C++ projects. Check out [docs/build.md](docs/build.md) for the detail instructions.

## Convert ONNX Model

We provide a conversion tool, named onnx2bnn, to convert an ONNX model to a dabnn model. We provide onnx2bnn pre-built binaries for all platforms in [GitHub Releases](https://github.com/JDAI-CV/dabnn/releases). For Linux users, the onnx2bnn pre-built binary is [AppImage](https://appimage.org) format, see https://appimage.org for details.
Expand Down
6 changes: 6 additions & 0 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,12 @@ dabnn_bireal18_imagenet_stem 43279353 ns 41533009 ns 14 <---

![Comparison](images/comparison_cn.png)

## 如何编译

我们已经提供预编译的 onnx2bnn 和 dabnn 的 Android package,不过如果需要在非 Android 的 ARM 设备上使用 dabnn,就需要自己编译它了。

如同大部分 C++ 项目,我们使用 CMake 构建系统。具体请看 [docs/build.md](docs/build.md)

## 如何转换 ONNX 模型

我们提供模型转换工具 onnx2bnn 将 ONNX 模型转换为 dabnn 格式的模型。在 [GitHub Releases](https://github.com/JDAI-CV/dabnn/releases) 里有各个平台的 onnx2bnn 预编译二进制文件,可以直接下载运行。Linux 用户我们提供的是 AppImage 格式的二进制文件,AppImage 的使用方法和其它相关信息请参考 https://appimage.org/。
Expand Down
51 changes: 51 additions & 0 deletions docs/build.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
## Build

We use CMake build system like most C++ projects.

### Build dabnn

Cross-compiling for ARMv8 Android:

1. Download and unzip Android NDK from https://developer.android.com/ndk/downloads.

1. Run cmake with the toolchain file, which determine the proper compiling toolchains.

```bash
mkdir build-dabnn
cd build-dabnn
cmake -DCMAKE_TOOLCHAIN_FILE=the_path_to_android_ndk/build/cmake/android.toolchain.cmake -DANDROID_ABI=arm64-v8a -DCMAKE_BUILD_TYPE=Release ..
```

**If this step fails, please check whether the toolchain file really exists on the path you set.**

1. Build

```bash
cmake --build .
```

For ARMv7, just replace `-DANDROID_ABI=arm64-v8a` with `-DANDROID_ABI=armeabi-v7a` in step 2.

For non-Android ARM devices, use the proper toolchain file for your device instead of the Android NDK toolchain file, or compile natively on your ARM device.

For non-ARM devices, only the unoptimized code will work. If you still want to build dabnn for non-ARM devices, pass `-DBNN_BUILD_MAIN_LIB=ON` in step 2.

### Build onnx2bnn

On non-ARM devices,

1. Run cmake

```bash
mkdir build-onnx2bnn
cd build-onnx2bnn
cmake ..
```

1. Build

```bash
cmake --build .
```

On ARM devices, pass `-DBNN_BUILD_MAIN_LIB=OFF` in step 1.

0 comments on commit c28e12c

Please sign in to comment.