From c28e12c6ea775fec1e7764938c3b74da2047e896 Mon Sep 17 00:00:00 2001 From: daquexian Date: Sun, 9 Jun 2019 22:53:17 +0800 Subject: [PATCH] Add instructions for building --- README.md | 6 ++++++ README_CN.md | 6 ++++++ docs/build.md | 51 +++++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 63 insertions(+) create mode 100644 docs/build.md diff --git a/README.md b/README.md index 6681ed6..81762bd 100644 --- a/README.md +++ b/README.md @@ -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. diff --git a/README_CN.md b/README_CN.md index 501a23a..02d3732 100644 --- a/README_CN.md +++ b/README_CN.md @@ -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/。 diff --git a/docs/build.md b/docs/build.md new file mode 100644 index 0000000..65c364c --- /dev/null +++ b/docs/build.md @@ -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.