Skip to main content

Inference APIs

This page covers Python ONNX Runtime, the image's C/C++ SDK and GStreamer-based applications. Sharing a model-directory convention does not make all runtimes interchangeable: the graph, compiled artifacts, runtime and application metadata must agree. TI documents these boundaries in the pinned runtime overview.

Tested software

Local evidence comes from the V1.1.0 development installation with TIDL 11_02_17_00, TI ONNX Runtime 1.23.0 and the on-board Edge AI SDK. The examples use the supplied YOLOX-nano model. The current board has Python 3.13.5 and NumPy 2.2.4; these are not the x86 compiler environment. The version map records the complete target audit. The image's 2026-08-19 build field is not its GitHub release date.

Model directory layout​

The supplied application bundles follow this convention, consistent with TI's AM62A deployment guide:

MODEL_DIR/
├── param.yaml # task type, pre- and post-processing parameters
├── dataset.yaml # class/label mapping where required
├── model/ # the ONNX or TFLite network
│ └── NAME.onnx
└── artifacts/ # TIDL compilation output for this TIDL version
├── allowedNode.txt
└── ...

Runtime-specific files can differ. Check the target SoC and the documented compatible software combination; a similar directory name alone does not establish compatibility. See Set up the toolchain.

Device access​

The local DMA-heap nodes are root-only, so these smoke tests use sudo. This is an installation-specific permission choice, not proof that every TIDL deployment must run as root. For a service, identify the required devices and grant controlled access. Do not use world-writable permissions or interpret a numeric -16 as a unique permission diagnosis.

Python: ONNX Runtime with the TIDL execution provider​

Download infer-yolox-nano.py. It checks the TI provider, the expected static input, output shapes and finite values over three calls. Its core session setup is:

import numpy as np
import onnxruntime as ort

model_dir = "/opt/model_zoo/ONR-OD-8200-yolox-nano-lite-mmdet-coco-416x416"
options = ort.SessionOptions()
options.graph_optimization_level = ort.GraphOptimizationLevel.ORT_DISABLE_ALL
options.add_session_config_entry("session.disable_input_validation", "1")
options.add_session_config_entry("session.disable_output_validation", "1")

session = ort.InferenceSession(
f"{model_dir}/model/yolox_nano_lite_416x416_20220214_model.onnx",
sess_options=options,
providers=["TIDLExecutionProvider", "CPUExecutionProvider"],
provider_options=[{"artifacts_folder": f"{model_dir}/artifacts"}, {}],
)

inp = session.get_inputs()[0]
assert inp.shape == [1, 3, 416, 416] and inp.type == "tensor(uint8)"
print(inp.name, inp.shape, inp.type)

frame = np.zeros([1, 3, 416, 416], dtype=np.uint8) # NCHW, RGB, 0-255
dets, labels = session.run(None, {inp.name: frame})
print(dets.shape, labels.shape) # (200, 5) (200,)

The I/O options follow the TI 1.23 wrapper, which accounts for TIDL tensor changes. They do not excuse checking your own inputs and outputs. Graph optimization must remain consistent with the artifacts.

Run the complete download with sudo python3 infer-yolox-nano.py. This supplied model reports 329/329 offloaded nodes in one subgraph. The three completed blank-input calls below are a smoke test, not a detection-accuracy or performance result:

Actual Mo62A execution of the downloadable Python smoke test: full offload, three finite-output calls and normal system state afterward

Notes:

  • This specific model takes NCHW uint8 input. Read each model's param.yaml and tensor metadata; do not infer type, normalization or channel order from “lite” in its name.
  • Keep CPUExecutionProvider available for supported CPU operations. It cannot execute a custom operator without an implementation.
  • Separate session creation, first-call and warmed-up measurements. See Benchmarks for raw timing data.

An installed module is not a validated inference path. Do not replace the image's TI runtime with a generic ONNX Runtime wheel.

For meaningful image/video inputs rather than this blank-input smoke test, use the new-model walkthrough and zone-occupancy application. That 8210 graph takes float32 RGB 0–255, unlike this supplied nano graph's uint8 input. Its downloadable model.py implements preprocessing, output decoding and bundle checks; logic.py and run_video.py add application events. Do not copy one model's tensor contract into another.

C/C++: the on-board Edge AI SDK​

The image installs a C/C++ SDK so inference programs compile on the board without cross-compilation:

ItemLocation
Headers/usr/include/edgeai/
Static libraries/usr/lib/edgeai/
CMake package/usr/lib/cmake/EdgeAI/EdgeAIConfig.cmake
TI runtime libraries/opt/ti/edgeai/lib/
Examples and guide/usr/share/edgeai-cpp-examples/ (source maintained in mo-examples)

The image-specific find_package(EdgeAI) configuration exposes EdgeAI::edgeai; additional application dependencies remain your responsibility. The supplied hello_inference example loads a model directory, runs inference and prints output tensors:

The installed SDK comment and older source guide still mention ONNX Runtime 1.15. That is stale documentation: the current C/C++ library's OrtGetApiBase reports 1.23.0, matching the Python runtime. Use the measured version map, actual library resolution and model tests, not that comment, when selecting dependencies.

cpp_demo_dir=$(mktemp -d /tmp/mo62a-hello-inference.XXXXXX)
cp -a /usr/share/edgeai-cpp-examples/hello_inference/. "$cpp_demo_dir/"
cmake -S "$cpp_demo_dir" -B "$cpp_demo_dir/build"
cmake --build "$cpp_demo_dir/build" --parallel 2
sudo "$cpp_demo_dir/build/hello_inference" \
-m /opt/model_zoo/ONR-OD-8200-yolox-nano-lite-mmdet-coco-416x416

The audit rebuilt this example in a new temporary directory and reran it successfully: 329/329 offloaded nodes, dets with 1000 float32 elements and labels with 200 int64 elements. This validates a blank-input example, not detection accuracy or every possible application.

Actual rebuilt Mo62A C++ example, resolved ONNX/YAML libraries, full node offload and two output tensors

Configuration emitted a CMake warning that /opt/ti/edgeai/lib could hide the system libyaml-cpp.so.0.8. ldd resolved the executable's YAML and ONNX libraries under that TI directory, and this run passed. The warning is not claimed fixed; inspect actual library resolution when changing the SDK or application dependencies.

The minimal linking pattern is:

cmake_minimum_required(VERSION 3.16)
project(my_infer CXX)
set(CMAKE_CXX_STANDARD 17)
find_package(EdgeAI REQUIRED)
add_executable(my_infer main.cpp)
target_link_libraries(my_infer PRIVATE EdgeAI::edgeai)

The API is TI's edgeai-dl-inferer (#include <ti_dl_inferer.h>): create a DLInferer from the model directory, fill its input buffers, call run() and read the outputs. app_edgeai in the same directory is the complete camera-to-HDMI application, and DEV_GUIDE.md documents the SDK in detail.

GStreamer pipelines​

The launcher and edgeai-gst-apps build video applications from YAML input/model/output settings. The tested Python/C++ paths combine GStreamer, inference and application-side processing. They must not be described as universally zero-copy or guaranteed fastest. TI's sample-app guide distinguishes these from OpTIFlow. Run your first NPU demo documents the actual Mo62A pipelines and development-environment changes.

Troubleshooting​

SymptomWhat to check
Create state function failed -1Read preceding target diagnostics; check versions, model integrity, operators, memory and shared-resource state.
Permission errorCheck the named device and process identity; numeric codes alone do not establish a permissions fault.
Unexpected input data typeMatch the type reported by get_inputs(); many models take uint8, not float32.
Fewer offloaded than total nodesInspect CPU operations and runtime support, then validate correctness and timing.
Slow initialization or first callMeasure initialization separately; investigate stalls instead of assuming all delays are normal.
Concurrent pipelines conflictInspect resource ownership, caps and queues; stop the other test gracefully to isolate the issue.

Source: inhandnet/mo-docs · 7ba0dc46