ONE - On-device Neural Engine
|
This document is based on the system where Ubuntu Desktop Linux 20.04 LTS is installed with default settings, and can be applied in other environments without much difference. For example, Ubuntu Desktop Linux 18.04 LTS environment is also supported but some additional steps may be required.
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
If you are using python3.12 or upper (ex. Ubuntu 24.04), or python 3.6 or under (ex. Ubuntu 18.04), as there is no TensorFlow2.12.1 package for python version, build may fail. Please install python3.8-venv additionally.
Additional install python3.8 if you are using Ubuntu 18.04
Additional install python 3.8 if you are using Ubuntu 24.04
Additional install libtsan_preinit.o manually if you are using Ubuntu 20.04 and gcc-9 (refer https://github.com/Samsung/ONE/issues/11202)
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 simple