Note that all files are installed under `/opt/trinity/`.
```console
-$ sudo apt install npu-engine npu-engine-example npu-engine-testdata
+$ sudo apt install npu-engine npu-engine-example
+(if needed)
+$ sudo apt install npu-engine-testdata npu-engine-testdata-triv240 npu-engine-testdata-triv242
...
$ ls /opt/trinity/lib
libmrpsim.a libmrpsim.so libnpu-engine.so pkgconfig
$ ls /opt/trinity/bin
apptests unittests
$ ls /opt/trinity/share/npu-engine/testdata
-TRIV221_8TOPS TRIV238_2TOPS
+TRIV221_8TOPS TRIV238_2TOPS TRIV240 TRIV242
```
# Artifactory RPM Repository
```console
$ yum list
Available Packages
-npu-engine.x86_64 2.5.1-0 Artifactory
-npu-engine-devel.x86_64 2.5.1-0 Artifactory
-npu-engine-example.x86_64 2.5.1-0 Artifactory
-npu-engine-utils.x86_64 2.5.1-0 Artifactory
+npu-engine.x86_64 2.6.1-0 Artifactory
+npu-engine-devel.x86_64 2.6.1-0 Artifactory
+npu-engine-example.x86_64 2.6.1-0 Artifactory
+npu-engine-utils.x86_64 2.6.1-0 Artifactory
$ yum install npu-engine
```
Using Zypper
```console
$ zypper search -s | grep artifactory
- | npu-engine | package | 2.5.1-0 | x86_64 | artifactory
- | npu-engine-devel | package | 2.5.1-0 | x86_64 | artifactory
- | npu-engine-example | package | 2.5.1-0 | x86_64 | artifactory
- | npu-engine-utils | package | 2.5.1-0 | x86_64 | artifactory
+ | npu-engine | package | 2.6.1-0 | x86_64 | artifactory
+ | npu-engine-devel | package | 2.6.1-0 | x86_64 | artifactory
+ | npu-engine-example | package | 2.6.1-0 | x86_64 | artifactory
+ | npu-engine-utils | package | 2.6.1-0 | x86_64 | artifactory
$ sudo zypper install npu-engine
```
## Example: apptest_tvn_triv2_example
This application ([tvn_triv2_example.cc](https://github.sec.samsung.net/AIP/NPU_SystemService/blob/tizen/tests/apptests/tvn_triv2_example.cc)) executes a given TRIV2 model using [libnpuhost.h](https://github.sec.samsung.net/AIP/NPU_SystemService/blob/tizen/include/host/libnpuhost.h).
-Note that the testdata used here follows the NPU binary format ([npubinfmt.h](https://github.sec.samsung.net/AIP/NPU_SystemService/blob/tizen/include/common/npubinfmt.h)).
+Note that the testdata used here follows the NPU binary format ([npubinfmt.h](https://github.sec.samsung.net/AIP/npubin-fmt/blob/master/include/npubinfmt.h)).
Also, TRIV2 currently works with npubinfmt v3 only.
-Let's assume you are testing the application in Ubuntu 18.04.
+Let's assume you are testing the application in Ubuntu 20.04.
```console
$ sudo apt-get install npu-engine-example npu-engine-testdata
$ cd /opt/trinity
If the build has finished successfully, you should find the built packages like below.
```console
$ ls ~/GBS-ROOT/local/repos/tizen/aarch64/RPMS/
-npu-engine-2.5.0-1.aarch64.rpm npu-engine-example-2.5.0-1.aarch64.rpm
-npu-engine-devel-2.5.0-1.aarch64.rpm npu-engine-utils-2.5.0-1.aarch64.rpm
+npu-engine-2.6.1-1.aarch64.rpm npu-engine-example-2.6.1-1.aarch64.rpm
+npu-engine-devel-2.6.1-1.aarch64.rpm npu-engine-utils-2.6.1-1.aarch64.rpm
```
You can test your packages after installing them.
[ in another shell ]
$ telnet localhost 5000
root:~> cd /mnt/RPMS
-root:~> rpm -ivh --force npu-engine-2.5.0-1.aarch64.rpm
-root:~> rpm -ivh --force npu-engine-example-2.5.0-1.aarch64.rpm
+root:~> rpm -ivh --force npu-engine-2.6.1-1.aarch64.rpm
+root:~> rpm -ivh --force npu-engine-example-2.6.1-1.aarch64.rpm
+root:~> rpm -ihv --force npubin-fmt-3.0.0-0.aarch64.rpm
root:~> /usr/lib64/npu-engine/bin/apptests/apptest_tvn_triv2 /usr/share/npu-engine/testdata/TRIV238_2TOPS/MAX_POOL_2D_000
```
root# cd /opt/trinity/bin/apptests/
-root# apptest_tvn_triv2 /opt/trinity/share/npu-engine/testdata/TRIV238_2TOPS/MOBILENET_V1
+root# apptest_tvn_triv2 /opt/trinity/share/npu-engine/testdata/TRIV238_2TOPS/MOBILENET_V1 -v 2.3
>>> Initializaing SPM with zero. It can be time-consuming...
>>> Initializaing SPM with zero. It can be time-consuming...
-[Core Name: NPCore0], [File Name: /opt/trinity/share/mRPsim/decoder-triv2-cp.bin], [Ver: 1]
+[Core Name: NPCore0], [File Name: /opt/trinity/share/mRPsim/decoder-0.29.0-cp.bin], [Ver: 1]
+ Section(.SRP.FLIH) Base (22000000) Size(36)
+...
+[APPTEST] apptest_tvn_triv2: PASSED
+
+root# apptest_tvn_triv2 /opt/trinity/share/npu-engine/testdata/TRIV242/MOBILENET_V1 -v 2.4
+>>> Initializaing SPM with zero. It can be time-consuming...
+>>> Initializaing SPM with zero. It can be time-consuming...
+[Core Name: NPCore0], [File Name: /opt/trinity/share/mRPsim/decoder-4.2.5-cp.bin], [Ver: 1]
Section(.SRP.FLIH) Base (22000000) Size(36)
...
[APPTEST] apptest_tvn_triv2: PASSED
## Prerequisites
-First of all, you have to install the petalinux SDK in your host PC (Ubuntu 18.04 recommended).
+First of all, you have to install the petalinux SDK in your host PC (Ubuntu 20.04 recommended).
Please refer to [here](PetaLinux.md) for detail instructions.
However, please note that if you are NOT supposed to update any source codes, skip the below FPGA-related descriptions.
$ cd meta-trinity
$ ls
build conf COPYING.MIT hw README.md recipes-app recipes-bsp recipes-ddk recipes-devtools recipes-kernel
-$ vim recipes-ddk/npu-engine/npu-engine_2.5.0.bb
+$ vim recipes-ddk/npu-engine/npu-engine_2.6.1.bb
[ ... ]
SRC_URI = "git://git@github.sec.samsung.net/AIP/NPU_SystemService.git;protocol=ssh;branch=tizen"
[ ... ]
[ ... ]
$ petalinux-build
$ ls build/tmp/deploy/rpm/aarch64 | grep npu-engine
-npu-engine-2.5.0-r0.aarch64.rpm
-npu-engine-testcases-2.5.0-r0.aarch64.rpm
+npu-engine-2.6.1-r0.aarch64.rpm
+npu-engine-testcases-2.6.1-r0.aarch64.rpm
```
As our FPGA board supports `ssh` connection, the created packages can be simply copied.
```
$ cd build/tmp/deploy/rpm/aarch64/
-$ scp npu-engine-2.5.0-r0.aarch64.rpm root@[FPGA IP Address]:.
-$ scp npu-engine-2.5.0-testcases-r0.aarch64.rpm root@[FPGA IP Address]:.
+$ scp npu-engine-2.6.1-r0.aarch64.rpm root@[FPGA IP Address]:.
+$ scp npu-engine-2.6.1-testcases-r0.aarch64.rpm root@[FPGA IP Address]:.
```
Then, you can install them using `rpm` command in the FPGA board.
```
$ ssh root@[FPGA IP Address]
[ ... ]
-# rpm -ivh npu-engine-2.5.0-r0.aarch64.rpm --force
+# rpm -ivh npu-engine-2.6.1-r0.aarch64.rpm --force
# ls -al /usr/lib/libnpu-engine.so
rwxr-xr-x 1 root root 210872 May 28 05:27 /usr/lib/libnpu-engine.so
-# rpm -ivh npu-engine-testcases-2.5.0-r0.aarch64.rpm --force
+# rpm -ivh npu-engine-testcases-2.6.1-r0.aarch64.rpm --force
# ls -al /usr/lib/npu-engine/bin/
drwxr-xr-x 2 root root 4096 May 28 05:24 apptests
drwxr-xr-x 2 root root 4096 May 28 05:24 unittests
```
-Also, please make sure that `source.sh` is executed after booting.
-```
-# pwd
-/home/root
-# source setting.sh
-# dmesg | tail
-[ 23.804902] triv2 402010000.triv2: misc device created!
-[ 23.830077] triv2 402010000.triv2: Trinity Vision2 (TRIV2) probed
-[ 23.877240] triv2 402010000.triv2: [0] /home/root/idu/cp/zero.bin -> 0x402000000
-[ 23.887010] triv2 402010000.triv2: [1] /home/root/idu/cp/data.bin -> 0x402000010
-[ 23.903432] triv2 402010000.triv2: [2] /home/root/idu/cp/code.bin -> 0x480100000
-[ 23.920371] triv2 402010000.triv2: [3] /home/root/idu/dsp/zero.bin -> 0x402100000
-[ 23.930675] triv2 402010000.triv2: [4] /home/root/idu/dsp/data.bin -> 0x402100010
-[ 23.948438] triv2 402010000.triv2: [5] /home/root/idu/dsp/code.bin -> 0x480600000
-```
-
## How to test features
NPU-DDK supports two types of test programs: `unittest` and `apptests`.
-rwxr-xr-x 1 root root 551016 Aug 24 02:19 unittest_ne_libnpuhost
```
-Any program in `unittests` can be runnable without arguments.
+Some Program in `unittests` can be runnable with NPU_VER environment variable.
```
# pwd
/home/root
# unittest_ne_libnpuhost
+root@xilinx-zcu102-2019_2:~# NPU_VER=2.3
root@xilinx-zcu102-2019_2:~# unittest_ne_libnpuhost
[==========] Running 33 tests from 1 test case.
[----------] Global test environment set-up.
-rwxr-xr-x 1 root root 47176 Aug 24 02:19 apptest_tvn_triv2_xml
```
-They may use test models stored in `/home/root/TRIV238_2TOPS` if necessary.
+They may use test models stored in `/home/root/TRIV238_2TOPS` or `/home/root/TRIV242` if necessary.
- `TRIV238_2TOPS`: TRIV v2.3.8 (2-TOPS) test models with NHWC format
+- `TRIV242`: TRIV v2.4.2 (4-TOPS) test models with NHWC format
Programs in `apptests` are linked to `libnpu-engine.so` and may require extra arguments.
The below shows example command lines for each apptest.
-m Mute stdout/stderr messages
-s Enable run sync mode
-o Enable output dump mode
+ -v <arg> Set NPU_VER [2.3|2.4] (default 2.4)
-h Show help messages
[APPTEST] apptest_tvn_triv2: SKIPPED
-# apptest_tvn_triv2 TRIV238_2TOPS/MOBILENET_V1
+# apptest_tvn_triv2 -v 2.3 TRIV238_2TOPS/MOBILENET_V1
+[APPTEST] apptest_tvn_triv2: PASSED
+
+# apptest_tvn_triv2 -v 2.4 TRIV242/MOBILENET_V1
[APPTEST] apptest_tvn_triv2: PASSED
-# apptest_tvn_triv2_dmabuf TRIV238_2TOPS/MOBILENET_V1
+# apptest_tvn_triv2_dmabuf -v 2.3 TRIV238_2TOPS/MOBILENET_V1
[APPTEST] apptest_tvn_triv2_dmabuf: PASSED
-# apptest_tvn_triv2_preempt TRIV238_2TOPS
+# apptest_tvn_triv2_preempt -v 2.3 TRIV238_2TOPS
[APPTEST] apptest_tvn_triv2_preempt: PASSED
-# apptest_tvn_triv2_profile TRIV238_2TOPS/MOBILENET_V1 -p visa
+# apptest_tvn_triv2_profile -v 2.3 TRIV238_2TOPS/MOBILENET_V1 -p visa
[ ... ]
[663] ADMA_OUT
Running Cycles : 631
<dirpath>TRIV238_2TOPS/MOBILENET_V2</dirpath>
</model>
</testcases>
-# apptest_tvn_triv2_xml model.xml
+# apptest_tvn_triv2_xml -v 2.3 model.xml
[APPTEST] apptest_tvn_triv2_xml: PASSED
-# apptest_tvn_triv2_sigkill TRIV238_2TOPS/MOBILENET_V1
+# apptest_tvn_triv2_sigkill -v 2.3 TRIV238_2TOPS/MOBILENET_V1
[APPTEST] apptest_tvn_triv2_sigkill: PASSED
-# apptest_tvn_triv2_interleave 10 TRIV238_2TOPS/MAX_POOL_2D_000,TRIV238_2TOPS/CONV_2D_300
+# apptest_tvn_triv2_interleave -v 2.3 10 TRIV238_2TOPS/MAX_POOL_2D_000,TRIV238_2TOPS/CONV_2D_300
[APPTEST] apptest_tvn_triv2_interleave: PASSED
-# apptest_tvn_triv2_aging TRIV238_2TOPS/CONV_2D_300 1 10
+# apptest_tvn_triv2_aging -v 2.3 TRIV238_2TOPS/CONV_2D_300 1 10
[APPTEST] apptest_tvn_triv2_aging: PASSED
-# apptest_tvn_triv2_aging TRIV238_2TOPS/CONV_2D_300 2 10
+# apptest_tvn_triv2_aging -v 2.3 TRIV238_2TOPS/CONV_2D_300 2 10
[APPTEST] apptest_tvn_triv2_aging: PASSED
-# apptest_tvn_triv2_aging TRIV238_2TOPS/CONV_2D_300 3 10
+# apptest_tvn_triv2_aging -v 2.3 TRIV238_2TOPS/CONV_2D_300 3 10
[APPTEST] apptest_tvn_triv2_aging: PASSED
-# apptest_tvn_triv2_aging TRIV238_2TOPS/CONV_2D_300 4 10
+# apptest_tvn_triv2_aging -v 2.3 TRIV238_2TOPS/CONV_2D_300 4 10
[APPTEST] apptest_tvn_triv2_aging: PASSED
-# apptest_tvn_triv2_bulk TRIV238_2TOPS
+# apptest_tvn_triv2_bulk -v 2.3 TRIV238_2TOPS
[APPTEST] apptest_tvn_triv2_bulk: PASSED (110), FAILED (0)
```
Optionally, you can change source codes and build packages manually. But, please make sure you added the [Artifactory](Artifactory.md) repository was added to your apt source list to resolve build dependencies.
First, clone the github repository and build using `debuild`.
-If some build-dependent packages are missing, please install them (e.g., `libmrpsim-dev`).
+If some build-dependent packages are missing, please install them (e.g., `libmrpsim-dev`,`npubin-fmt`).
```console
$ git clone https://github.sec.samsung.net/AIP/NPU_SystemService
$ cd NPU_SystemService
If the build has finished successfully, you should find the built packages like below.
```console
$ ls ../*.deb
-../npu-engine_2.5.0_amd64.deb ../npu-engine-example_2.5.0_amd64.deb
-../npu-engine-dev_2.5.0_amd64.deb ../npu-engine-utils_2.5.0_amd64.deb
+../npu-engine_2.6.1_amd64.deb ../npu-engine-example_2.6.1_amd64.deb
+../npu-engine-dev_2.6.1_amd64.deb ../npu-engine-utils_2.6.1_amd64.deb
```
Then, install your packages manually.
After `npu-engine-dev` is successfully installed, your application can access the required header files in `/opt/trinity/include`.
```console
-$ dpkg -i ../npu-engine_2.5.0_amd64.deb ../npu-engine-dev_2.5.0_amd64.deb
+$ dpkg -i ../npu-engine_2.6.1_amd64.deb ../npu-engine-dev_2.6.1_amd64.deb
$ ls /opt/trinity/lib
libnpu-engine.so
$ ls /opt/trinity/include/npu-engine
-libnpuhost.h npubinfmt.h typedef.h
+libnpuhost.h
```
## Application Build
```
libnpuhost.h: The user APIs that NPU Engine provides
-npubinfmt.h: The format of NPU model binary
-typedef.h: The type definitions used in NPU Engine
```
Thus, what you need to do is just to include these headers and use the defined APIs in your application. Here are a few APIs that you may use frequently:
* Linux Kernel Driver: [AIP/NPU_Linux-kernel](https://github.sec.samsung.net/AIP/NPU_Linux-kernel)
* Bootstrap for FastModels: [AIP/NPU_bootstrap](https://github.sec.samsung.net/AIP/NPU_bootstrap)
* Bitbake recipes for FPGA: [AIP/meta-trinity](https://github.sec.samsung.net/AIP/meta-trinity)
+* NPU Binary Metadata Format: [AIP/npubin-fmt](https://github.sec.samsung.net/AIP/npubin-fmt)
## Features
std::cerr << " -d <arg> \t Set a device node path (e.g., /dev/triv2-0)\n";
std::cerr << " -n <arg> \t Set output notimode [intr|polling]\n";
std::cerr << " -p <arg> \t Set profile level [visa|layer]\n";
+ std::cerr << " -v <arg> \t Set NPU_VER [2.3|2.4] (default 2.4)";
std::cerr << " -t \t\t Enable trinity data format\n";
std::cerr << " -m \t\t Mute stdout/stderr messages\n";
std::cerr << " -s \t\t Enable run sync mode\n";