Skip to main content

RKNN async inference Python bindings

Project description

ztu_somemodelruntime_ez_rknn_async

A better ORT-style RKNPU2 API for Python and C++

Supported Python versions: 3.7+


🚀 Feature Comparison

Feature This Project Official SDK
Model Loading & Basic Inference ✅ Supported ✅ Supported
Multi-core Tensor Parallel Inference ✅ Supported ✅ Supported
Multi-core Data Parallel Inference ✅ Supported ❌ Not Supported
Pipeline-based Async Inference ✅ Supported ⚠️ Limited (Depth = 1)
True Async Inference (Callback/Future) ✅ Supported ❌ Not Supported
Multi-batch Data Parallel Inference ✅ Supported ⚠️ Limited (Fixed batch/4D only)
Zero-copy Inference ✅ Supported (via OrtValue/io_binding API) ❌ Not Supported
Multi model weight sharing ✅ Supported ❌ Not Supported
Custom Operator Plugins ✅ Supported ❌ Not Supported
Read model embed string ✅ Supported ❌ Not Supported
Python and C++ APIs ✅ Supported ⚠️ Proprietary C API
API Style 🚀 ORT-like (Easy migration) ⚙️ Proprietary (Complex)
Zero Dependencies ✅ Yes (NumPy only) ❌ No
Break Other Packages ✅ No ⚠️ Yes (https://github.com/airockchip/rknn-toolkit2/issues/414)
Open Source 🔓 Yes (AGPLv3) 🔒 No

Installation

pip install ztu-somemodelruntime-ez-rknn-async

or manually build a wheel:

python3 -m pip wheel . -w dist --no-deps

Usage

The usage is similar to ONNXRuntime Python API, you can load a .rknn model and use run() or run_async() to do inference. To use these advanced features, you need to configure corresponding provider_options or run_options (refer to the documentation).

C++ API

The public C++17 API is available from <ztu/somemodelruntime_rknn.hpp> in the ztu::somemodelruntime::rknn namespace. It intentionally implements the dense-tensor subset needed by RKNN instead of defining or depending on the real Ort namespace. Code that does not include ONNX Runtime in the same translation unit can use a namespace alias to minimize migration changes:

#include <ztu/somemodelruntime_rknn.hpp>

#include <array>

namespace Ort = ztu::somemodelruntime::rknn;

int main() {
  Ort::Env env;
  Ort::RknnProviderOptions provider_options;
  provider_options.layout = Ort::Layout::Nchw;

  Ort::SessionOptions session_options;
  session_options.SetRknnProviderOptions(provider_options);
  Ort::Session session(env, "model.rknn", session_options);

  std::array<int64_t, 4> shape{1, 3, 224, 224};
  std::array<float, 1 * 3 * 224 * 224> input{};
  auto input_value = Ort::Value::CreateTensor<float>(
      Ort::MemoryInfo::CreateCpu(), input.data(), input.size(),
      shape.data(), shape.size());

  const char *input_names[] = {session.GetInputName(0).c_str()};
  auto outputs = session.Run(Ort::RunOptions{}, input_names, &input_value, 1,
                             nullptr, 0);
  const float *output = outputs[0].GetTensorData<float>();
  (void)output;
}

For zero-copy inference, construct an Ort::IoBinding, bind CPU or RKNPU2 Value objects, and call session.Run(run_options, binding). Session-aware RKNPU2 buffers and external dma-bufs are created with CreateIoValue() and CreateIoValueFromDmaBuf().

Build and install the native package with:

cmake -S . -B build/cpp -DZTU_SOMEMODELRUNTIME_RKNN_BUILD_PYTHON=OFF
cmake --build build/cpp -j
cmake --install build/cpp --prefix /your/prefix

Downstream projects can then use:

find_package(ztu_somemodelruntime_rknn CONFIG REQUIRED)
target_link_libraries(your_target PRIVATE ztu::somemodelruntime_rknn)

The regular Session::Run path preserves the Python API's copied float-output behavior. Native dtype/layout buffers and true zero-copy operation are exposed through IoBinding. Sparse tensors, string tensors, maps/sequences, graph optimization settings, and execution-provider management are outside this RKNN-focused compatibility subset.

Documentation

I don't know if it's a good idea to document this library, but anyway, there's an AI generated one that's generally okay: https://deepwiki.com/happyme531/ztu_somemodelruntime_ez_rknn_async , and another one https://mintlify.wiki/happyme531/ztu_somemodelruntime_ez_rknn_async

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ztu_somemodelruntime_ez_rknn_async-0.10.0.tar.gz (95.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

ztu_somemodelruntime_ez_rknn_async-0.10.0-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl (1.3 MB view details)

Uploaded CPython 3.14manylinux: glibc 2.26+ ARM64manylinux: glibc 2.28+ ARM64

File details

Details for the file ztu_somemodelruntime_ez_rknn_async-0.10.0.tar.gz.

File metadata

File hashes

Hashes for ztu_somemodelruntime_ez_rknn_async-0.10.0.tar.gz
Algorithm Hash digest
SHA256 0f809d556fbaa9fc3b75ef62f2e96e687880f82e35a24a933bd17e60989b7c40
MD5 a3c46a2b5c8e8a85edfe9e4a83c94824
BLAKE2b-256 72ffd8219e03327b085a08f833e9624dbffc87435701c99484abe5a1340278cc

See more details on using hashes here.

Provenance

The following attestation bundles were made for ztu_somemodelruntime_ez_rknn_async-0.10.0.tar.gz:

Publisher: release-wheels.yml on happyme531/ztu_somemodelruntime_ez_rknn_async

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ztu_somemodelruntime_ez_rknn_async-0.10.0-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for ztu_somemodelruntime_ez_rknn_async-0.10.0-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 6bc7ee531e0c6e313dcb07d81e687c55b29716167650a66922d88846572dc0ba
MD5 87855eadc460769018ea0ff94bf88c22
BLAKE2b-256 8d0ee274687d4aed3a476e4bbbde99675725633703e7330e18008cc3c0405da9

See more details on using hashes here.

Provenance

The following attestation bundles were made for ztu_somemodelruntime_ez_rknn_async-0.10.0-cp314-cp314-manylinux_2_26_aarch64.manylinux_2_28_aarch64.whl:

Publisher: release-wheels.yml on happyme531/ztu_somemodelruntime_ez_rknn_async

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ztu_somemodelruntime_ez_rknn_async-0.10.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ztu_somemodelruntime_ez_rknn_async-0.10.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 8484d6e696f9156c02f70f5359d3d38e7917fe624bc097e759c2878d24834f6c
MD5 0903b975281d87a3ec5d8eccbd8e4e3b
BLAKE2b-256 b349b7e2a667d1bbad6b3cd3f429efc59e9eaae0877162373f736858b5d58079

See more details on using hashes here.

Provenance

The following attestation bundles were made for ztu_somemodelruntime_ez_rknn_async-0.10.0-cp313-cp313-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-wheels.yml on happyme531/ztu_somemodelruntime_ez_rknn_async

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ztu_somemodelruntime_ez_rknn_async-0.10.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ztu_somemodelruntime_ez_rknn_async-0.10.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 6ff335b0d8cd00b240b45f57d6f2f7e066baf8959f859dcbb0f1ead0d4912a37
MD5 e6fd4da0f40f360809f2472ccf0c38f5
BLAKE2b-256 b3418c39c02325fb0a6c4259e9b39daa773fc97203323f22cc8bb74177220592

See more details on using hashes here.

Provenance

The following attestation bundles were made for ztu_somemodelruntime_ez_rknn_async-0.10.0-cp312-cp312-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-wheels.yml on happyme531/ztu_somemodelruntime_ez_rknn_async

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ztu_somemodelruntime_ez_rknn_async-0.10.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ztu_somemodelruntime_ez_rknn_async-0.10.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 c809b1a94f433a6866db62cc2e3d0a8f3cbd90dea655eaa5667ad2e8b9d90dc5
MD5 e0483ad6e5658952d95f0245f230874c
BLAKE2b-256 8d8e05f8e6e5cec62895041052c82e2e26314fbcb99a93157e9df67422a65311

See more details on using hashes here.

Provenance

The following attestation bundles were made for ztu_somemodelruntime_ez_rknn_async-0.10.0-cp311-cp311-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-wheels.yml on happyme531/ztu_somemodelruntime_ez_rknn_async

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ztu_somemodelruntime_ez_rknn_async-0.10.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ztu_somemodelruntime_ez_rknn_async-0.10.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 f3a01246936f9d9522994e4c70df6e867e7e2365bf62863c0e71e89c09692100
MD5 e47c3a1cf313f8a58ce90101af31574f
BLAKE2b-256 1cb29af06c1224ee4670abeccb263bce6de7839457f6ffac41aa1b13c388945f

See more details on using hashes here.

Provenance

The following attestation bundles were made for ztu_somemodelruntime_ez_rknn_async-0.10.0-cp310-cp310-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-wheels.yml on happyme531/ztu_somemodelruntime_ez_rknn_async

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ztu_somemodelruntime_ez_rknn_async-0.10.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ztu_somemodelruntime_ez_rknn_async-0.10.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 7ae88376b5b1c6cb0aab1836c8f9d26f623cc699b4beca626a02df180daf4313
MD5 7181561cce631b67ab3d6bd51a9e42f5
BLAKE2b-256 4ad8254d93a23dc21c54485c30803a591e3debcc633e836fe921ea7224c62d56

See more details on using hashes here.

Provenance

The following attestation bundles were made for ztu_somemodelruntime_ez_rknn_async-0.10.0-cp39-cp39-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-wheels.yml on happyme531/ztu_somemodelruntime_ez_rknn_async

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ztu_somemodelruntime_ez_rknn_async-0.10.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ztu_somemodelruntime_ez_rknn_async-0.10.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 bfcc0b875f0839a660241f50ff13e06946f70d566f36e1a733e7c90081b12d0f
MD5 85c16267a481760c7c84093f80c2e55b
BLAKE2b-256 4cf4dd39bf929481eb8e96f893fc5530de05bd043cbcadec35993c64f2b7a783

See more details on using hashes here.

Provenance

The following attestation bundles were made for ztu_somemodelruntime_ez_rknn_async-0.10.0-cp38-cp38-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-wheels.yml on happyme531/ztu_somemodelruntime_ez_rknn_async

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file ztu_somemodelruntime_ez_rknn_async-0.10.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for ztu_somemodelruntime_ez_rknn_async-0.10.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 ea1245bc005ba709b41432eb09c6333d12c2e9cc015211c48135f7221c50b179
MD5 87c6e58bf3615f1997d793d7d92583c9
BLAKE2b-256 44d0ef2cf73cd21578cf24acef7b21fa1cc843205344a057161402f7e6b2c7f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for ztu_somemodelruntime_ez_rknn_async-0.10.0-cp37-cp37m-manylinux_2_17_aarch64.manylinux2014_aarch64.whl:

Publisher: release-wheels.yml on happyme531/ztu_somemodelruntime_ez_rknn_async

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page