|
ONE - On-device Neural Engine
|
This document is based on the system where Ubuntu Desktop Linux 22.04 LTS is installed with default settings, and can be applied in other environments without much difference.
If you are going to build this project, the following modules must be installed on your system:
In the Ubuntu, you can easily install it with the following command.
If your linux system does not have the basic development configuration, you will need to install more packages. A list of all packages needed to configure the development environment can be found in the https://github.com/Samsung/ONE/blob/master/infra/docker/focal/Dockerfile file.
Here is a summary of it
Supported platforms:
Supported Python versions:
[!NOTE] Ubuntu 20.04 support is unavailable as ppa:deadsnake has ended providing Python3.10 as Ubuntu 20.04 is now end-of-life. We are seeking alternate solution for this issue and when available, this document will be updated with the information.
In a typical linux development environment, including Ubuntu, you can build the compiler with a simple command like this:
Build artifacts will be placed in build folder.
To run unit tests:
Above steps will build all the modules in the compiler folder. There are modules that are currently not active. To build only as of now active modules of the compiler, we provide a preset of modules to build with below command:
With this command, ~/.local folder will contain all files in release. If you have added ~/.local/bin in PATH, then you will now have latest compiler binaries.
Build target folder can be customized by NNCC_WORKSPACE environment, as we may want to separate debug and release builds.
will build debug version in build/debug folder, and
will build release version in build/release folder.
To build for Windows, we use MinGW(Minimalist GNU for Windows). Here you can download a tool that includes it.
NNAS_BUILD_PREFIX is the path to directory where compiler-build-artifacts will be stored.--preset is the one that specifies a version you will install. You can see infra/packaging/preset/ directory for more details and getting latest version.--prefix is the install directory.Some modules are availble to run in Ubuntu/ARM32 through cross building.
While configuring the build, some modules need to execute tools for generating test materials and they need to execute in the host(x86-64). So some modules are needed to build the tools for host before cross building.
Cross build overall steps are like, (1) configure for host (2) build tools for host (3) configure for ARM32 target (4) and then build for ARM32 target.
Unit tests can also run in target device. But value test needs to run TensorFlow lite to get expected results, and it would be a task to do this so the data files from host execution are used instead.
Thus to run the unit tests in the target, running in host is needed in prior.
You should prepare Ubuntu/ARM32 root file system for cross compilation. Please refer how-to-cross-build-runtime-for-arm.md for preparation.
You can set ROOTFS_ARM environment variable if you have in alternative folder.
Some external projects from source are not "cross compile ready with CMake" projects. This experimental project prepared some patches for this. Just remove the source and stamp file like below and the make will prepare patch applied source codes.
To cross build, infra/nncc/Makefile.arm32 file is provided as an example to work with make command.
First make will run above steps (1), (2) and (3). Second make will run (4).
Preprequisite for testing in ARM32 device.
You can also run unit tests in ARM32 Ubuntu device with cross build results. First you need to run the test in host to prepare files that are currently complicated in target device. For value test with python, separate venv is requried. make target test_venv will prepare this.
NOTE: this assumes
build folder to target orONE folder with NFS on the target would be simpleThere's a potential known build error when attempting to cross-compile for ARM32 using GCC 10.5. You might encounter an error: comparison of unsigned expression in ‘< 0’ is always false [-Werror=type-limits] reported from the CircleNodeMixins.h file. This is likely GCC's bug in this specific version. There's a workaround for it though - you can apply the following changes to both for loops in the CircleNodeMixins.h: