Build & Test from source

April 28, 2020 ยท View on GitHub

You can build onnc source with either CMake or Automake building system.

Building with CMake

There are 2 modes, Release mode and debug mode, provided in CMake building system.

Release mode

Recommended for common use.

Release mode will build onnc with basic optimizations, and skip debug informations.

Notice: Release mode will NOT build unit tests.

Step 1: Configure

$ mkdir -p build && cd build
$ cmake -DCMAKE_BUILD_TYPE=Release ..

It will create build directory, get into it and configure with Release build type.

Step 2: Build

$ make -j4

It will compile sources with 4 threads concurrently. You can modify -j4 option to meet your needs.

Step 3: Install

$ sudo make install

It will install essential files to /usr/local.

Debug mode

Recommended for development use.

Debug mode will build onnc with debug settings, unit tests and some debug informations.

Step 1: Configure

$ mkdir -p build && cd build
$ cmake -DCMAKE_BUILD_TYPE=Debug ..

It will create build directory, get into it and configure with Debug build type.

Step 2: Build

$ make -j4

It will compile sources with 4 threads concurrently. You can modify -j4 option to meet your needs.

Step 3: Test

$ ctest

It will trigger all unit tests by CTest.

If you want to execute single unit test, you can find it in build/tools/unittests directory.

Step 4: Install

$ sudo make install

It will install essential files to /usr/local.

Advanced configurations

You can override default configurations by simply add -DENTRY=VALUE options to the configure command. The ENTRY and VALUE can be replaced according to the following table:

"Path string" of value means you have to provide a string of a directory path, and "File path string" means you have to provide a string of a file path.

EntryAvailable valuesDefaultDescription
CMAKE_INSTALL_PREFIXPath string/usr/localPath to install onnc into
CMAKE_BUILD_TYPEDebug,ReleaseReleaseBuild mode
LLVM_CONFIGFile path stringSystem default pathPath of llvm-config
ONNX_INCLUDE_DIRPath stringSystem default pathPath to include directory of onnx
ONNX_LIBRARIESFile path string listSystem default pathsPath of onnx and onnx_proto libraries
ONNX_LIBRARIE_onnxFile path stringSystem default pathPath of onnx library
ONNX_LIBRARIE_onnx_protoFile path stringSystem default pathPath of onnx_proto library
ONNX_NAMESPACEstringonnxNamespace of onnx
SKYPAT_INCLUDE_DIRPath string/usr/local/includePath to include directory of SkyPat
SKYPAT_LIBRARIESFile path stringSystem default pathPath of SkyPat library
TARGET_ALLON,OFFONWhether to build all targets
TARGET_SOPHONON,OFFONWhether to build Sophon targets
TARGET_X86ON,OFFONWhether to build X86 targets
USE_LLVMON,OFFONWhether to use LLVM
ENABLE_CLOCK_GETTIMEON,OFFOFFWhether to enable clock_gettime function
ENABLE_GETTIMEOFDAYON,OFFONWhether to enable gettimeofday function
ENABLE_PTHREADON,OFFONWhether to enable pthread
ENABLE_UNITTESTON,OFFONWhether to build unit test
ENABLE_WERRORON,OFFOFFWhether to use -Werror flag
USE_MKLDNNON,OFFONWhether to use MKLDNN for libonnc-rt
MKLDNN_ROOTFile path stringSystem default pathPath of MKLDNN libraries

Use cmake -L .. inside build directory to get more detailed options.