RKNN models can reference operators not built into the runtime. These are supplied as shared library (Documentation Index
Fetch the complete documentation index at: https://mintlify.com/happyme531/ztu_somemodelruntime_ez_rknn_async/llms.txt
Use this file to discover all available pages before exploring further.
.so) files that export a get_rknn_custom_op() function. EZ RKNN Async loads and registers these plugins at session creation time via the custom_op_paths and custom_op_default_path provider options.
Build-time requirement
Custom op support is compiled in only whenrknn_custom_op.h is present at build time. The C++ preprocessor macro ZTU_EZRKNN_ASYNC_HAS_CUSTOM_OP is set to 1 when the header is found. If your build lacks the header, calling any custom-op option emits a UserWarning and raises RuntimeError.
Loading a specific plugin file
Pass one or more.so paths to custom_op_paths:
.so must export a symbol named exactly get_rknn_custom_op. If the symbol is missing, session creation raises a RuntimeError with the dlsym error detail. If the file cannot be opened at all, a UserWarning is emitted first (to surface the potential RKNN stability risk), then a RuntimeError is raised.
Loading from the default plugin directory
Setcustom_op_default_path=True to scan the platform’s standard plugin directory and load every file matching librkcst_*.so:
| Platform | Scanned directory |
|---|---|
| Linux | /usr/lib/rknpu/op_plugins/ |
| Android (64-bit) | /vendor/lib64/ |
| Android (32-bit) | /vendor/lib/ |
UserWarning is emitted and no plugins are loaded. Individual plugin load failures emit per-file warnings rather than aborting the whole scan.
Why custom ops force disable_dup_context
By default, EZ RKNN Async creates additional RKNN contexts with rknn_dup_context to share the loaded model across worker threads. There is a known stability issue in the RKNN runtime when custom operators are registered on duplicated contexts. To avoid this:
- Requesting any custom-op loading automatically sets
disable_dup_context=Truefor that session, regardless of the value you pass explicitly. - Each worker thread initializes its own independent context via
rknn_init. - The session emits a
UserWarningat startup to make this behavior visible:Custom op loading requested; dup_context is disabled for this session to avoid known RKNN stability issues.
Complete example
Provider option keys
Both spelling variants are accepted and behave identically:| Key | Alias | Type | Description |
|---|---|---|---|
custom_op_paths | custom_op_path | str or List[str] | Path(s) to .so plugin files. |
custom_op_default_path | load_custom_ops_from_default_path | bool | Scan the platform default plugin directory. |