AI, Computer Vision and Machine Learning on Toradex AM69/TDA4-based Modules
Introduction
This article provides instructions for integrating Machine Learning hardware acceleration on the Aquila AM69/TDA4 System-on-Module (SoM) with Torizon OS. The Aquila AM69/TDA4 uses TI's C7x-MMA DSP together with the TIDL/TIOVX userspace stack to accelerate AI workloads.
This article complies with the Typographic Conventions for Toradex Documentation.
Prerequisites
- Hardware prerequisites:
- Software prerequisites:
- A configured build environment as described in the Host Machine Setup for Building with Yocto documentation
- Read the Build Torizon OS from Source With Yocto Project/OpenEmbedded article
Setup Instructions
Set Up the Yocto Project Sources
Initialize the Yocto Project environment with the Toradex manifest for the Scarthgap release, then synchronize the required repositories:
$ repo init -u git://git.toradex.com/toradex-manifest.git -b scarthgap -m torizon/default.xml
$ repo sync
The Edge AI device tree overlay is available starting from Torizon OS 7.6.1. If you pin the manifest to a release tag, use 7.6.1 or later.
After synchronization, source the setup-environment script and configure the build for the Aquila AM69:
$ MACHINE=aquila-am69 source setup-environment aquila-am69-image
From this point, all instructions assume that the aquila-am69-image directory is the current working directory.
Download the Required Layers
Clone the additional Yocto layers required for TI Edge AI support into the layers directory. Each layer is checked out at the revision used by TI's Processor SDK Analytics 11.01.07.05 release. For J784S4-based SoCs, this release builds the ti-vision-apps Linux libraries from the REL.PSDK.ANALYTICS.11.00.00.06 tag, which is compatible with the SDK 11.00-based Edge AI firmware. The revisions in Pin TI Recipe Revisions match the ones these layers use:
$ git clone --branch 11.01.07 https://git.ti.com/git/arago-project/meta-arago ../layers/meta-arago
$ git clone --branch 11.01.07.05 https://git.ti.com/git/edgeai/meta-edgeai ../layers/meta-edgeai
$ git clone --branch 11.01.07.05 https://github.com/TexasInstruments/meta-tisdk ../layers/meta-tisdk
$ git clone --branch scarthgap https://github.com/kraj/meta-clang ../layers/meta-clang
$ git -C ../layers/meta-clang checkout aef850f7fa53121c74b244b7ae40d31fb9809ccf
The Aquila AM69/TDA4 Edge AI firmware is based on TI's Processor SDK 11.00, and the Linux libraries must come from a compatible release. Linux libraries from newer SDK releases change the data structures shared between Linux and the DSP cores, therefore the remote cores reject TIOVX nodes or the applications stop responding during initialization.
Configure and Build the Image
Update Configuration Files
After cloning the required layers, update the bblayers.conf and local.conf files to include the new layers and configure the build according to the following steps:
-
Add the cloned layers to the
EXTRALAYERSvariable inconf/bblayers.conf:bblayers.confEXTRALAYERS ?= " \
${OEROOT}/layers/meta-clang \
${OEROOT}/layers/meta-openembedded/meta-multimedia \
${OEROOT}/layers/meta-arago/meta-arago-distro \
${OEROOT}/layers/meta-arago/meta-arago-extras \
${OEROOT}/layers/meta-arago/meta-arago-test \
${OEROOT}/layers/meta-tisdk/meta-ti-foundational \
${OEROOT}/layers/meta-edgeai \
" -
Accept the
commerciallicense flag used byedgeai-tiovx-appsand disable the TI Arago SDK source-package feature inconf/local.conf:local.confLICENSE_FLAGS_ACCEPTED:append = " commercial"
INHERIT:remove = "sourceipk" -
Set the
REPODIRvariable inconf/local.conffile to use an isolated repository checkout. Make sure to replacepath/to/repodirwith a writable directory outside anyrepoworkspace:local.confREPODIR = "path/to/repodir"warningThe
ti-vision-appsrecipe uses therepofetcher, which can reuserepometadata from the parent workspace. SetREPODIRto a writable directory outside anyrepoworkspace to ensure an isolated checkout and avoid removing unrelated projects during futurerepo syncusage.The
repofetcher also reuses an existing checkout inREPODIRwithout initializing it again. If you change theti-vision-appsrelease tag, delete the contents of theREPODIRdirectory before building, or the build silently uses the previously fetched sources. -
Add the TI Edge AI packages to the image in
conf/local.conf:local.confCORE_IMAGE_BASE_INSTALL:append:aquila-am69 = " \
edgeai-gst-apps \
edgeai-gst-apps-source \
edgeai-tidl-models \
edgeai-tiovx-apps \
edgeai-tiovx-apps-source \
edgeai-tiovx-modules \
tdx-edgeai-optlinks \
ti-edgeai-firmware \
ti-tidl \
python3-pillow \
python3-onnx \
"
# Skip building the ONNX unit tests, which are not required on the target
PACKAGECONFIG:remove:pn-onnx = "unittests"The remaining TI Edge AI libraries, such as
ti-vision-apps,edgeai-tiovx-kernels, andedgeai-apps-utils, are installed automatically as dependencies of these packages. Theti-edgeai-firmwareandtdx-edgeai-optlinkspackages must be listed explicitly, because no other package depends on them:ti-edgeai-firmware: Provides the firmware for the C7x DSP and R5F remote cores. Without it, the remote cores do not boot.tdx-edgeai-optlinks: Creates the compatibility symbolic links under/opt, described in OSTree Relocation.
The
python3-pillowandpython3-onnxpackages are only required by the examples in Run a Model on the C7x-MMA.
Custom Layer Usage
Building the image with the TI Edge AI stack requires patches to the TI layers. To keep these changes separated from the upstream layers, create a custom layer and apply the patches on this custom layer:
$ cd ../layers/
$ bitbake-layers create-layer meta-customer
$ tree meta-customer/
meta-customer
├── conf
│ └── layer.conf
├── COPYING.MIT
├── README
└── recipes-example
└── example
└── example_0.1.bb
4 directories, 4 files
After creating the custom layer, set up the following directory structure for the TI Edge AI stack patches:
meta-customer
├── conf
│ ├── layer.conf
│ └── machine
│ └── aquila-am69-extra.conf
├── recipes-core
│ └── tdx-edgeai-optlinks
│ ├── files
│ │ └── 50-tdx-edgeai-optlinks.conf
│ └── tdx-edgeai-optlinks.bb
└── recipes-tisdk
├── edgeai-components
│ ├── edgeai-apps-utils.bbappend
│ ├── edgeai-dl-inferer.bbappend
│ ├── edgeai-gst-apps.bbappend
│ ├── edgeai-gst-plugins.bbappend
│ ├── edgeai-tidl-models.bbappend
│ ├── edgeai-tiovx-apps.bbappend
│ ├── edgeai-tiovx-kernels.bbappend
│ └── edgeai-tiovx-modules.bbappend
├── ti-psdk-rtos
│ ├── ti-edgeai-firmware.bbappend
│ └── ti-vision-apps.bbappend
└── ti-tidl
└── ti-tidl.bbappend
10 directories, 15 files
Layer Configuration
The aquila-am69-extra.conf file defines additional machine settings for the Aquila AM69/TDA4 SoM. Add the following lines to include the Edge AI device tree overlay in the boot configuration and keep the Aquila AM69 device trees in the build:
TEZI_EXTERNAL_KERNEL_DEVICETREE_BOOT:append:aquila-am69 = " aquila-am69_edgeai_overlay.dtbo"
KERNEL_DEVICETREE_PREFIX:remove:aquila-am69 = "ti/k3-j784s4"
The meta-edgeai layer sets KERNEL_DEVICETREE_PREFIX for all J784S4-based machines. When this variable is set, the meta-ti layer replaces the machine's device tree list with TI's own J784S4 device trees, which excludes the Aquila AM69 device trees from the image. Removing the prefix for the aquila-am69 machine keeps the Toradex device trees in the build.
Next, update the layer.conf file to include the additional machine configuration:
include conf/machine/aquila-am69-extra.conf
Finally, add the meta-customer layer to the end of the existing EXTRALAYERS list in bblayers.conf. Do not add a second EXTRALAYERS ?= assignment, because BitBake ignores it when the variable is already set:
EXTRALAYERS ?= " \
${OEROOT}/layers/meta-clang \
${OEROOT}/layers/meta-openembedded/meta-multimedia \
${OEROOT}/layers/meta-arago/meta-arago-distro \
${OEROOT}/layers/meta-arago/meta-arago-extras \
${OEROOT}/layers/meta-arago/meta-arago-test \
${OEROOT}/layers/meta-tisdk/meta-ti-foundational \
${OEROOT}/layers/meta-edgeai \
+ ${OEROOT}/layers/meta-customer \
"
Recipe Fixes
TI Edge AI stack recipes require modifications to build correctly in the Toradex BSP environment. The .bbappend files in the meta-customer layer contain the necessary changes to ensure compatibility.
The ti-vision-apps.bb and ti-tidl.bb recipes define the CROSS_COMPILE_LINARO variable assuming Arago's default target toolchain. Building Torizon OS requires the aarch64-tdx-linux- toolchain prefix instead. Update the CROSS_COMPILE_LINARO variable in the ti-vision-apps.bbappend and ti-tidl.bbappend files to use the correct toolchain prefix.
do_compile() {
CROSS_COMPILE_LINARO=${TARGET_PREFIX} \
LINUX_SYSROOT_ARM=${STAGING_DIR_TARGET} \
TREAT_WARNINGS_AS_ERROR=0 \
GCC_LINUX_ARM_ROOT= \
GCC_LINUX_ARM_ROOT_A72= \
LINUX_FS_PATH=${STAGING_DIR_TARGET} \
SOC=${PLAT_SOC} \
oe_runmake yocto_build
}
DEPENDS += "nlohmann-json stb"
do_compile() {
ln -snf ${TARGET_FS} ${WORKDIR}/targetfs
PSDK_INSTALL_PATH=${WORKDIR} \
IVISION_PATH=${TARGET_FS}${includedir}/processor_sdk/ivision \
VISION_APPS_PATH=${TARGET_FS}${includedir}/processor_sdk/vision_apps \
APP_UTILS_PATH=${TARGET_FS}${includedir}/processor_sdk/app_utils \
TIOVX_PATH=${TARGET_FS}${includedir}/processor_sdk/tiovx \
LINUX_FS_PATH=${TARGET_FS} \
CONCERTO_ROOT=${S}/concerto \
TF_REPO_PATH=${S}/tensorflow \
ONNX_REPO_PATH=${S}/onnxruntime \
TIDL_PROTOBUF_PATH=${S}/protobuf \
GCC_LINUX_ARM_ROOT= \
TARGET_SOC=${PLAT_SOC} \
CROSS_COMPILE_LINARO=${TARGET_PREFIX} \
LINUX_SYSROOT_ARM=${STAGING_DIR_TARGET} \
TREAT_WARNINGS_AS_ERROR=0 \
oe_runmake
}
The edgeai-tiovx-apps.bb and edgeai-gst-apps.bb recipes conflict with the stricter security hardening flags enabled in the Torizon OS build configuration. To prevent format-security warnings from causing build failures, add the SECURITY_STRINGFORMAT:remove = "-Werror=format-security" setting to edgeai-tiovx-apps.bbappend and edgeai-gst-apps.bbappend.
Additionally, add the ALLOW_EMPTY:${PN} = "1" setting to edgeai-gst-apps.bbappend to allow the main package to be empty.
ALLOW_EMPTY:${PN} = "1"
SECURITY_STRINGFORMAT:remove = "-Werror=format-security"
SECURITY_STRINGFORMAT:remove = "-Werror=format-security"
The upstream edgeai-dl-inferer.bb recipe targets an older ONNX Runtime API than the version provided by ti-tidl-osrt.bb. Disable ONNX Runtime support in edgeai-dl-inferer.bbappend to avoid incompatibility issues.
EXTRA_OECMAKE:append = " -DUSE_ONNX_RT=OFF"
The TIDL TensorFlow Lite delegate and the ONNX Runtime execution provider load the TIDL runtime libraries by their unversioned names, such as libvx_tidl_rt.so. Yocto installs these unversioned symbolic links only in the ti-tidl-dev development package by default. Add the following settings to ti-tidl.bbappend to install them with the main ti-tidl package:
FILES_SOLIBSDEV = ""
FILES:${PN} += "${libdir}/libvx_tidl_rt.so ${libdir}/libtidl_tfl_delegate.so ${libdir}/libtidl_onnxrt_EP.so"
INSANE_SKIP:${PN} += "dev-so"
The edgeai-tidl-models.bb recipe downloads precompiled models from TI's Model Zoo. The C7x firmware only runs models compiled for the same TIDL firmware version, and the Model Zoo selected by the upstream recipe targets a newer firmware than the one used in this article. The 11_00_04_00 Model Zoo contains models compiled for the SDK 11.00 TIDL firmware used in this article, therefore override the do_fetch task in edgeai-tidl-models.bbappend to download the compatible 11_00_04_00 Model Zoo:
do_fetch() {
mkdir -p ${WORKDIR}/script
cd ${WORKDIR}/script
wget https://raw.githubusercontent.com/TexasInstruments/edgeai-gst-apps/${SRCREV}/download_models.sh
chmod +x ./download_models.sh
export SOC="${SOC}"
export EDGEAI_SDK_VERSION=11_00_04_00
./download_models.sh --recommended
}
To run your own models, compile them with the Edge AI TIDL Tools for C7x firmware version 11_00_00_00. Models compiled for a different firmware version fail to load, and the C7x core log reports a Network version error.
OSTree Relocation
Torizon OS uses OSTree to manage system and over-the-air (OTA) updates, which relocates the /opt directory to /var/rootdirs/opt during the build process. Therefore, upstream recipes that install files under /opt have those files removed during the build, resulting in missing content on the target device without triggering build errors.
For this reason, the .bbappend files in the meta-customer layer relocate the TI Edge AI files from /opt to ${datadir}/tdx-edgeai. Add the following do_install:append() logic to the corresponding .bbappend files to ensure that these files are preserved in the final image.
For each recipe, set TDX_EDGEAI_OPT_DIRS to the directories that must be relocated and replace PACKAGE_FILES_ASSIGNMENT with the corresponding package file assignment shown in the following table.
TDX_EDGEAI_OPT_DIRS = "<directories>"
do_install:append() {
for dir in ${TDX_EDGEAI_OPT_DIRS}; do
if [ -e ${D}/opt/$dir ]; then
mkdir -p ${D}${datadir}/tdx-edgeai
mv ${D}/opt/$dir ${D}${datadir}/tdx-edgeai/$dir
fi
done
rmdir ${D}/opt 2>/dev/null || true
}
PACKAGE_FILES_ASSIGNMENT
| File | TDX_EDGEAI_OPT_DIRS | PACKAGE_FILES_ASSIGNMENT |
|---|---|---|
edgeai-apps-utils.bbappend | edgeai-apps-utils | FILES:${PN}-source += "${datadir}/tdx-edgeai/*" |
edgeai-dl-inferer.bbappend | edgeai-dl-inferer | FILES:${PN}-source += "${datadir}/tdx-edgeai/*" |
edgeai-gst-apps.bbappend | edgeai-gst-apps | FILES:${PN}-source += "${datadir}/tdx-edgeai/*" |
edgeai-gst-plugins.bbappend | edgeai-gst-plugins | FILES:${PN}-source += "${datadir}/tdx-edgeai/*" |
edgeai-tidl-models.bbappend | model_zoo | FILES:${PN} += "${datadir}/tdx-edgeai/*" |
edgeai-tiovx-apps.bbappend | edgeai-tiovx-apps | FILES:${PN}-source += "${datadir}/tdx-edgeai/*" |
edgeai-tiovx-kernels.bbappend | edgeai-tiovx-kernels | FILES:${PN}-source += "${datadir}/tdx-edgeai/*" |
edgeai-tiovx-modules.bbappend | edgeai-tiovx-modules | FILES:${PN}-source += "${datadir}/tdx-edgeai/*" |
ti-vision-apps.bbappend | imaging vision_apps vx_app_arm_remote_log.out | FILES:${PN} += "${datadir}/tdx-edgeai/*" |
ti-tidl.bbappend | tidl_test | FILES:${PN} += "${datadir}/tdx-edgeai/*" |
After relocating the TI Edge AI files, update the 50-tdx-edgeai-optlinks.conf configuration file to create compatibility symbolic links from the original paths under /opt to the relocated content under /usr/share/tdx-edgeai.
L+ /opt/model_zoo - - - - /usr/share/tdx-edgeai/model_zoo
L+ /opt/imaging - - - - /usr/share/tdx-edgeai/imaging
L+ /opt/vision_apps - - - - /usr/share/tdx-edgeai/vision_apps
L+ /opt/vx_app_arm_remote_log.out - - - - /usr/share/tdx-edgeai/vx_app_arm_remote_log.out
L+ /opt/edgeai-gst-apps - - - - /usr/share/tdx-edgeai/edgeai-gst-apps
L+ /opt/edgeai-gst-plugins - - - - /usr/share/tdx-edgeai/edgeai-gst-plugins
L+ /opt/edgeai-tiovx-apps - - - - /usr/share/tdx-edgeai/edgeai-tiovx-apps
L+ /opt/edgeai-tiovx-kernels - - - - /usr/share/tdx-edgeai/edgeai-tiovx-kernels
L+ /opt/edgeai-tiovx-modules - - - - /usr/share/tdx-edgeai/edgeai-tiovx-modules
L+ /opt/edgeai-dl-inferer - - - - /usr/share/tdx-edgeai/edgeai-dl-inferer
L+ /opt/edgeai-apps-utils - - - - /usr/share/tdx-edgeai/edgeai-apps-utils
L+ /opt/tidl_test - - - - /usr/share/tdx-edgeai/tidl_test
Next, add the tdx-edgeai-optlinks.bb recipe to install the tmpfiles.d configuration that creates these symbolic links:
SUMMARY = "Compatibility symlinks for EdgeAI content relocated out of /opt"
SECTION = "admin"
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://${COMMON_LICENSE_DIR}/MIT;md5=0835ade698e0bcf8506ecda2f7b4f302"
SRC_URI = "file://50-tdx-edgeai-optlinks.conf"
S = "${WORKDIR}"
COMPATIBLE_MACHINE = "aquila-am69"
inherit allarch
do_install() {
install -d ${D}${sysconfdir}/tmpfiles.d
install -m 0644 ${S}/50-tdx-edgeai-optlinks.conf ${D}${sysconfdir}/tmpfiles.d/
}
FILES:${PN} = "${sysconfdir}/tmpfiles.d/50-tdx-edgeai-optlinks.conf"
INHIBIT_DEFAULT_DEPS = "1"
Pin TI Recipe Revisions
The TI Edge AI recipes are provided by layers outside the Toradex BSP and may reference source repositories that change independently. To ensure that the build uses known working source revisions, set the following variables in the .bbappend files in the meta-customer layer. The ti-vision-apps recipe is pinned by the release tag in its SRC_URI, and the ti-tidl recipe uses one SRCREV per source repository:
| File | Variable | Value |
|---|---|---|
edgeai-apps-utils.bbappend | SRCREV | 5a5a694ae02f0d2e4e39028b847e1c777c465cbf |
edgeai-dl-inferer.bbappend | SRCREV | f1592e41f8f859fc345865fa4e15efb85d06d3ec |
edgeai-gst-apps.bbappend | SRCREV | 799dcbda54f829eb7b234bf93a5669addcc1b919 |
edgeai-gst-plugins.bbappend | SRCREV | fea12213b449fc1ea117ad5f0016c08f417ab46d |
edgeai-tidl-models.bbappend | SRCREV | 799dcbda54f829eb7b234bf93a5669addcc1b919 |
edgeai-tiovx-apps.bbappend | SRCREV | bb50f5ab5765f9b634cd40d744399dcbce296c52 |
edgeai-tiovx-kernels.bbappend | SRCREV | b41bef631fcf037e8cb8b754d9db0d42d9ce3210 |
edgeai-tiovx-modules.bbappend | SRCREV | 16ea980baf1b9c6549bd5cc33aa94ea9c351eb01 |
ti-edgeai-firmware.bbappend | SRCREV | e00793be1432e02103b71c37bc612e1f34a7a388 |
ti-vision-apps.bbappend | SRC_URI | repo://git.ti.com/git/processor-sdk/psdk_repo_manifests.git;protocol=https;branch=refs/tags/REL.PSDK.ANALYTICS.11.00.00.06;manifest=vision_apps_yocto.xml |
ti-tidl.bbappend | SRCREV_arm-tidl | 298ea671212768a73a744b9d7476fbfcc627a666 |
ti-tidl.bbappend | SRCREV_concerto | f5541b85b9973ca47680d1a6d970bf61a126daa8 |
ti-tidl.bbappend | SRCREV_onnxruntime | f145bec7bee26b9dfa43b3e07645ee1a5f8b8140 |
ti-tidl.bbappend | SRCREV_tensorflow | 422156a973b23bab6b86176a245a66193dccb995 |
ti-tidl.bbappend | SRCREV_protobuf | f0dc78d7e6e331b8c6bb2d5283e06aa26883ca7c |
Complete .bbappend Example
Some .bbappend files receive changes from more than one of the previous sections. For reference, the following example shows the complete edgeai-gst-apps.bbappend file, which combines the source revision pin, the recipe fixes, and the OSTree relocation logic:
SRCREV = "799dcbda54f829eb7b234bf93a5669addcc1b919"
TDX_EDGEAI_OPT_DIRS = "edgeai-gst-apps"
do_install:append() {
for dir in ${TDX_EDGEAI_OPT_DIRS}; do
if [ -e ${D}/opt/$dir ]; then
mkdir -p ${D}${datadir}/tdx-edgeai
mv ${D}/opt/$dir ${D}${datadir}/tdx-edgeai/$dir
fi
done
rmdir ${D}/opt 2>/dev/null || true
}
FILES:${PN}-source += "${datadir}/tdx-edgeai/*"
ALLOW_EMPTY:${PN} = "1"
SECURITY_STRINGFORMAT:remove = "-Werror=format-security"
Build the Image
After making all the necessary configurations, initialize a Git repository in the meta-customer layer. Torizon OS requires all custom layers to be version-controlled with Git because their revision information is included in the OSTree metadata used by the system update and OTA mechanisms.
$ cd ../layers/meta-customer/
$ git init
$ git add .
$ git commit -m "create meta-customer layer"
$ cd ../../aquila-am69-image
Finally, build the Torizon OS minimal image:
$ bitbake torizon-minimal
Optimize Yocto Build RAM and CPU Usage
Your computer may run out of RAM while compiling some packages (such as Qt, in the tdx-reference-multimedia-image).
To reduce RAM usage, set the environment variables PARALLEL_MAKE and BB_NUMBER_THREADS to a limited number of threads.
PARALLEL_MAKE: number of threads used bymake.BB_NUMBER_THREADS: number of threads used bybitbake. SettingBB_NUMBER_THREADSalso limits the number of download and configuration threads.
$ PARALLEL_MAKE="-j 4" BB_NUMBER_THREADS="6" bitbake <image>
Alternatively, to apply these settings across all builds using the same build directory, add the following lines to the conf/local.conf file in your build directory. This eliminates the need to specify the environment variables each time you run bitbake.
PARALLEL_MAKE = "-j 4"
BB_NUMBER_THREADS = "6"
To verify that BitBake is using the configured values, run the following command. The output should match the values specified in conf/local.conf:
$ bitbake -e | grep -E '^(PARALLEL_MAKE|BB_NUMBER_THREADS)='
BB_NUMBER_THREADS="6"
PARALLEL_MAKE="-j 4"
If a build fails due to lack of RAM, some files could be corrupted. Trying to build again may not solve this issue. In this situation:
- Delete the corrupted package
state - Delete all temporary files
- Attempt to build the image again
After the build completes, flash the generated image to the target module using Toradex Easy Installer.
Verify the Edge AI Stack
Check the Remote Cores
The device tree overlay reserves the memory required by the remote cores, and the Linux remoteproc driver loads the TI Edge AI firmware at boot. Verify that all four C7x DSP cores and all six main domain R5F cores are running. The MCU R5F core is managed by the bootloader, so it reports attached instead:
# cat /sys/class/remoteproc/remoteproc*/state | sort | uniq -c
1 attached
10 running
Make sure that the kernel log does not report bad phdr errors, which indicate that the reserved memory regions do not match the firmware:
# dmesg | grep "bad phdr"
The command should not return any output.
Run the TIOVX Tests
Every TI Edge AI test requires the SOC environment variable, which is not set automatically. Pass it explicitly when running the tests.
The test applications read sample images from the directory set in the EDGEAI_DATA_PATH environment variable. The sample data is not included in the image, so the EDGEAI_DATA_PATH Not Defined and Unable to open file (null)/... messages are expected. The tests still create and run each processing graph on the hardware accelerators and remote cores.
Run the TIOVX modules test, which exercises the multi-scaler, color conversion, mosaic, LDC, VISS, pyramid, DOF and SDE modules:
# sudo env SOC=j784s4 edgeai-tiovx-modules-test
[ERROR] 97: main: EDGEAI_DATA_PATH Not Defined!!
APP: Init ... !!!
115.754995 s: MEM: Init ... !!!
115.755032 s: MEM: Initialized DMA HEAP (fd=5) !!!
115.755158 s: MEM: Init ... Done !!!
115.755172 s: IPC: Init ... !!!
115.785438 s: IPC: Init ... Done !!!
REMOTE_SERVICE: Init ... !!!
REMOTE_SERVICE: Init ... Done !!!
115.793882 s: GTC Frequency = 200 MHz
APP: Init ... Done !!!
...
All tests complete!
APP: Deinit ... !!!
REMOTE_SERVICE: Deinit ... !!!
REMOTE_SERVICE: Deinit ... Done !!!
116.073936 s: IPC: Deinit ... !!!
116.082679 s: IPC: DeInit ... Done !!!
116.082726 s: MEM: Deinit ... !!!
116.082866 s: DDR_SHARED_MEM: Alloc's: 111 alloc's of 130917293 bytes
116.082881 s: DDR_SHARED_MEM: Free's : 111 free's of 130917293 bytes
116.082901 s: DDR_SHARED_MEM: Open's : 0 allocs of 0 bytes
116.082912 s: MEM: Deinit ... Done !!!
APP: Deinit ... Done !!!
Then, run the TIOVX application tests:
# cd /opt/edgeai-tiovx-apps/bin/Release && sudo env SOC=j784s4 ./edgeai-tiovx-apps-test
[TIOVX_MODULES][ERROR] 119: main: EDGEAI_DATA_PATH Not Defined!!
APP: Init ... !!!
129.039716 s: MEM: Init ... !!!
129.039755 s: MEM: Initialized DMA HEAP (fd=5) !!!
129.039862 s: MEM: Init ... Done !!!
129.039875 s: IPC: Init ... !!!
129.069425 s: IPC: Init ... Done !!!
REMOTE_SERVICE: Init ... !!!
REMOTE_SERVICE: Init ... Done !!!
129.077948 s: GTC Frequency = 200 MHz
APP: Init ... Done !!!
...
All tests complete!
APP: Deinit ... !!!
REMOTE_SERVICE: Deinit ... !!!
REMOTE_SERVICE: Deinit ... Done !!!
129.487671 s: IPC: Deinit ... !!!
129.493019 s: IPC: DeInit ... Done !!!
129.493059 s: MEM: Deinit ... !!!
129.493074 s: DDR_SHARED_MEM: Alloc's: 189 alloc's of 197831084 bytes
129.493084 s: DDR_SHARED_MEM: Free's : 189 free's of 197831084 bytes
129.493093 s: DDR_SHARED_MEM: Open's : 0 allocs of 0 bytes
129.493106 s: MEM: Deinit ... Done !!!
APP: Deinit ... Done !!!
Both tests pass when they reach All tests complete!, report no TIVX_CMD_NODE_CREATE failed errors, and free every shared memory allocation, which means that the Alloc's and Free's counts are equal.
Run a Model on the C7x-MMA
To verify that inference runs on the C7x-MMA, run the cat detection demo. The demo includes two scripts that detect cats in a sample image with models from the Model Zoo included in the image:
tflite-cat-detection-demo.py: Runs the SSDLite MobileDet model with TensorFlow Lite and the TIDL delegate.onnx-cat-detection-demo.py: Runs the SSDLite MobileNetV2 model with ONNX Runtime and the TIDL execution provider.
Download and extract the demo on the module:
# cd /tmp
# wget https://docs.toradex.com/118622-aquila-am69-cat-detection-demo.tgz
# tar xzf 118622-aquila-am69-cat-detection-demo.tgz
Run the TensorFlow Lite demo with the included sample image. The --save option writes the image with the detected bounding boxes to tflite_output.jpg:
# sudo env SOC=j784s4 python3 tflite-cat-detection-demo.py --image image.jpeg --save
[TFLite] Running TFLite SSD MobileDet DSP inference...
Number of subgraphs:1 , 129 nodes delegated out of 129 nodes
APP: Init ... !!!
479.180702 s: MEM: Init ... !!!
479.180748 s: MEM: Initialized DMA HEAP (fd=6) !!!
479.180858 s: MEM: Init ... Done !!!
479.180877 s: IPC: Init ... !!!
479.210107 s: IPC: Init ... Done !!!
REMOTE_SERVICE: Init ... !!!
REMOTE_SERVICE: Init ... Done !!!
479.217458 s: GTC Frequency = 200 MHz
APP: Init ... Done !!!
...
[TFLite][INFO] Output image with detections saved as tflite_output.jpg
APP: Deinit ... !!!
REMOTE_SERVICE: Deinit ... !!!
REMOTE_SERVICE: Deinit ... Done !!!
479.382271 s: IPC: Deinit ... !!!
479.387733 s: IPC: DeInit ... Done !!!
479.387797 s: MEM: Deinit ... !!!
479.387813 s: DDR_SHARED_MEM: Alloc's: 10 alloc's of 10420960 bytes
479.387826 s: DDR_SHARED_MEM: Free's : 10 free's of 10420960 bytes
479.387838 s: DDR_SHARED_MEM: Open's : 0 allocs of 0 bytes
479.387853 s: MEM: Deinit ... Done !!!
APP: Deinit ... Done !!!
{
"tflite": {
"runtime": "TFLite",
"inference_time_ms": 6.19,
"detections": [
{
"label": "cat",
"score": 0.7944,
"box": [
"xmin: 122",
"ymin: 43",
"xmax: 1089",
"ymax: 1388"
]
}
]
}
}
Then, run the ONNX Runtime demo. The --save option writes the image with the detected bounding boxes to onnx_output.jpg:
# sudo env SOC=j784s4 python3 onnx-cat-detection-demo.py --image image.jpeg --save
[ONNX] Running ONNX SSD MobileNetV2 Lite inference...
...
libtidl_onnxrt_EP loaded 0x55a870e6e0
Final number of subgraphs created are : 1, - Offloaded Nodes - 469, Total Nodes - 469
APP: Init ... !!!
165.414308 s: MEM: Init ... !!!
165.414352 s: MEM: Initialized DMA HEAP (fd=5) !!!
165.414463 s: MEM: Init ... Done !!!
165.414485 s: IPC: Init ... !!!
165.446620 s: IPC: Init ... Done !!!
REMOTE_SERVICE: Init ... !!!
REMOTE_SERVICE: Init ... Done !!!
165.459755 s: GTC Frequency = 200 MHz
APP: Init ... Done !!!
...
[ONNX][INFO] Output image with detections saved as onnx_output.jpg
APP: Deinit ... !!!
REMOTE_SERVICE: Deinit ... !!!
REMOTE_SERVICE: Deinit ... Done !!!
165.593643 s: IPC: Deinit ... !!!
165.600114 s: IPC: DeInit ... Done !!!
165.600166 s: MEM: Deinit ... !!!
165.600190 s: DDR_SHARED_MEM: Alloc's: 8 alloc's of 6865024 bytes
165.600200 s: DDR_SHARED_MEM: Free's : 8 free's of 6865024 bytes
165.600209 s: DDR_SHARED_MEM: Open's : 0 allocs of 0 bytes
165.600223 s: MEM: Deinit ... Done !!!
APP: Deinit ... Done !!!
{
"onnx": {
"runtime": "ONNX",
"inference_time_ms": 6.61,
"detections": [
{
"label": "cat",
"score": 0.9479,
"box": [
"xmin: 130",
"ymin: 75",
"xmax: 1062",
"ymax: 1387"
]
}
]
}
}
The Number of subgraphs line in the TensorFlow Lite output and the Offloaded Nodes count in the ONNX Runtime output show that all model nodes are delegated to the C7x-MMA. The demos report the detected cats, their confidence scores, and the inference time.