You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+134-1Lines changed: 134 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -4,10 +4,142 @@ Rust bindings for the Rockchip RKNN Runtime API (librknnrt.so), enabling deploym
4
4
5
5
> These bindings do **not** require redistributing the C headers from the Rockchip rknpu2 SDK. The sys crate contains bindgen bindings, but bindgen is not part of the build process.
6
6
7
+
## Overview
8
+
9
+
This crate provides safe, idiomatic Rust abstractions over the Rockchip RKNN runtime API, enabling efficient deployment and inference of deep learning models on Rockchip NPU hardware. It's designed for production use in embedded systems, IoT devices, and edge computing applications where Rockchip NPUs are deployed.
10
+
7
11
## Requirements
8
12
9
13
- Rockchip NPU compatible with `librknnrt` or `librknnmrt` libraries
10
14
- Rust 1.70+ (edition 2021)
15
+
- Linux environment (primary target)
16
+
- Supported NPU families: RK35xx, RK3576, and others compatible with RKNN API v2.3.2
17
+
18
+
## Features
19
+
20
+
-**Safe Rust Abstractions**: Memory-safe wrappers around the C API with proper error handling
21
+
-**Model Management**: Load, query, and manage RKNN models with type-safe interfaces
22
+
-**Inference Pipeline**: Set inputs, run inference, and retrieve outputs with zero-copy buffer support
23
+
-**Hardware Optimization**: Configure NPU core usage and batch processing for optimal performance
24
+
-**Flexible API Loading**: Choose between linked and runtime-loaded RKNN libraries
25
+
-**Comprehensive Querying**: Access model metadata, tensor attributes, and performance information
26
+
-**Multi-format Support**: Handle various tensor formats (NCHW, NHWC) and data types
27
+
-**Production Ready**: Based on the stable **rknpu2 SDK v2.3.2**
28
+
-**Comprehensive Error Handling**: Custom error types with detailed error information
29
+
-**Memory-safe Operations**: Safe tensor operations and buffer management
30
+
31
+
## Project Structure
32
+
33
+
```
34
+
crates/
35
+
├── rknpu2/ # High-level Rust API wrapper
36
+
├── rknpu2-sys/ # Low-level FFI bindings
37
+
└── rktensor/ # Tensor operations and utilities
38
+
```
39
+
40
+
## Installation
41
+
42
+
Add to your `Cargo.toml`:
43
+
44
+
```toml
45
+
[dependencies]
46
+
rknpu2 = { version = "0.1", features = ["rk35xx"] }
47
+
48
+
# For runtime library loading (optional)
49
+
rknpu2 = { version = "0.1", features = ["rk35xx", "libloading"] }
50
+
51
+
# For RK3576 specific features
52
+
rknpu2 = { version = "0.1", features = ["rk3576"] }
53
+
```
54
+
55
+
## API Overview
56
+
57
+
### Core Types
58
+
59
+
-**`RKNN<A>`**: Main struct for model management and inference
60
+
-**`Input`**: Represents model input tensors with various data types and formats
61
+
-**`Output`**: Handles model output retrieval with flexible buffer management
62
+
-**`Query`**: Trait for querying model metadata and attributes
63
+
64
+
### Key Methods
65
+
66
+
-**`RKNN::new()`**: Create RKNN context from model data
67
+
-**`set_inputs()`**: Configure model inputs before inference
68
+
-**`run()`**: Execute model inference
69
+
-**`get_outputs()`**: Retrieve inference results
70
+
-**`query()`**: Get model information and attributes
0 commit comments