• Home
  • History
  • Annotate
Name Date Size #Lines LOC

..17-Mar-2025-

common/H17-Mar-2025-15185

config/H17-Mar-2025-2522

example/H17-Mar-2025-9,3597,068

figures/H17-Mar-2025-

frameworks/native/H17-Mar-2025-37,16427,298

interfaces/H17-Mar-2025-5,552561

test/H17-Mar-2025-79,40749,543

.gitignoreH A D17-Mar-2025268 2520

BUILD.gnH A D17-Mar-20251 KiB3530

LICENSEH A D17-Mar-202510.1 KiB177150

OAT.xmlH A D17-Mar-20251.8 KiB3616

README.mdH A D17-Mar-20253.5 KiB6446

README_zh.mdH A D17-Mar-20253.5 KiB6446

bundle.jsonH A D17-Mar-20252.5 KiB7473

neural-network-runtime-guidelines.mdH A D17-Mar-202535.8 KiB697569

README.md

1# Neural Network Runtime
2
3## Introduction
4
5Neural Network Runtime (NNRt) functions as a bridge to connect the upper-layer AI inference framework and bottom-layer acceleration chip, implementing cross-chip inference computing of AI models.
6
7As shown in Figure 1, NNRt opens Native APIs for the AI inference framework to access. Currently, NNRt interconnects with the built-in [MindSpore Lite](https://gitee.com/openharmony/third_party_mindspore) inference framework of the system. In addition, NNRt opens HDI APIs for device-side AI acceleration chips (such as NPUs and DSPs) to access the OpenHarmony hardware ecosystem. AI applications can directly use underlying chips to accelerate inference and computing through the AI inference framework and NNRt.
8
9NNRt and MindSpore Lite use MindIR unified intermediate representation to reduce unnecessary model conversion in the intermediate process, making model transfer more efficient.
10
11Generally, the AI application, AI inference engine, and NNRt are in the same process, and the chip driver runs in another process. The transmission of models and computing data between the two processes should be implemented by IPC. NNRt architecture implements the HDI client based on the HDI APIs. Accordingly, chip vendors need to implement and open the HDI services through HDI APIs.
12
13**Figure 1** NNRt architecture
14!["NNRt architecture"](./figures/neural_network_runtime.png)
15
16## Directory Structure
17
18```text
19/foundation/ai/neural_network_runtime
20├── common                         # Common functions
21├── figures                        # Images referenced by README
22├── example                        # Development samples
23│   ├── deep_learning_framework    # Application/Inference framework development samples
24│   └── drivers                    # Device driver development samples
25├── frameworks
26│   └── native                     # Framework code
27│       └── ops                    # Operator header files and implementation
28├── interfaces                     # APIs
29│   ├── innerkits                  # Internal APIs
30│   └── kits                       # External APIs
31└── test                           # Test cases
32    ├── system_test                # System test cases
33    └── unittest                   #  Unit test cases
34```
35
36## Compilation and Building
37
38In the root directory of the OpenHarmony source code, call the following command to compile NNRt separately:
39```shell
40./build.sh --product-name rk3568 --ccache --build-target neural_network_runtime --jobs 4
41```
42> **Note:**
43--product-name: product name, for example, <b>Hi3516DV300</b> and <b>rk3568</b>.
44--ccache: The cache function is used during compilation.
45--build-target: name of the compiled component.
46--jobs: number of compilation threads, which can accelerate compilation.
47
48## Description
49
50### API Description
51
52- [Native API reference](https://gitee.com/openharmony/docs/tree/master/zh-cn/application-dev/reference/apis-neural-network-runtime-kit)
53- [HDI API reference](https://gitee.com/openharmony/drivers_interface/tree/master/nnrt)
54
55### How to Use
56
57- For details about AI inference engine/application development, see Neural Network Runtime App Development Guide.
58- For details about how to develop AI acceleration chip drivers and devices, see Neural Network Runtime Device Development Guide.
59
60## Repositories Involved
61
62- [neural_network_runtime](https://gitee.com/openharmony/neural_network_runtime)
63- [third_party_mindspore](https://gitee.com/openharmony/third_party_mindspore)
64

README_zh.md

1# Neural Network Runtime
2
3## 简介
4
5Neural Network Runtime(NNRt, 神经网络运行时)是面向AI领域的跨芯片推理计算运行时,作为中间桥梁连通上层AI推理框架和底层加速芯片,实现AI模型的跨芯片推理计算。
6
7如图1所示,NNRt开放北向Native接口供AI推理框架接入,当前NNRt对接了系统内置的[MindSpore Lite](https://gitee.com/openharmony/third_party_mindspore)推理框架。同时NNRt开放南向HDI接口,供端侧AI加速芯片(如NPU、DSP等)接入OpenHarmony硬件生态。AI应用通过AI推理框架和NNRt能直接使用底层芯片加速推理计算。
8
9Neural Network Runtime与MindSpore Lite使用MindIR统一模型的中间表达,减少中间过程不必要的模型转换,使得模型传递更加高效。
10
11通常,AI应用、AI推理引擎、Neural Network Runtime处在同一个进程下,芯片驱动运行在另一个进程下,两者之间需要借助进程间通信(IPC)传递模型和计算数据。Neural Network Runtime根据HDI接口实现了HDI客户端,相应的,芯片厂商需要根据HDI接口实现并开放HDI服务。
12
13**图1** Neural Network Runtime架构图
14!["Neural Network Runtime架构图"](./figures/zh-cn_neural_network_runtime_intro.jpg)
15
16## 目录
17
18```text
19/foundation/ai/neural_network_runtime
20├── common                         # 公共功能
21├── figures                        # README引用的图片目录
22├── example                        # 开发样例目录
23│   ├── deep_learning_framework    # 应用/推理框架开发样例存放目录
24│   └── drivers                    # 设备驱动开发样例存放目录
25├── frameworks
26│   └── native                     # 框架代码存放目录
27│       └── ops                    # 算子头文件和实现存放目录
28├── interfaces                     # 接口存放目录
29│   ├── innerkits                  # 系统内部接口文件存放目录
30│   └── kits                       # 对外开放接口文件存放目录
31└── test                           # 测试用例存放目录
32    ├── system_test                # 系统测试用例存放目录
33    └── unittest                   # 单元测试用例存放目录
34```
35
36## 编译构建
37
38在OpenHarmony源码根目录下,调用以下指令,单独编译Neural Network Runtime。
39```shell
40./build.sh --product-name rk3568 --ccache --build-target neural_network_runtime --jobs 4
41```
42> **说明:**
43--product-name:产品名称,例如Hi3516DV300、rk3568等。
44--ccache:编译时使用缓存功能。
45--build-target: 编译的部件名称。
46--jobs:编译的线程数,可加速编译。
47
48## 说明
49
50### 接口说明
51
52- Native接口文档请参考:[Native接口](https://gitee.com/openharmony/docs/tree/master/zh-cn/application-dev/reference/apis-neural-network-runtime-kit)53- HDI接口文档请参考:[HDI接口](https://gitee.com/openharmony/docs/blob/master/zh-cn/device-dev/reference/hdi-apis/_n_n_rt.md)54
55### 使用说明
56
57- AI推理引擎/应用开发请参考:[Neural Network Runtime对接AI推理框架开发指导](./neural-network-runtime-guidelines.md)。
58- AI加速芯片驱动/设备开发请参考:[Neural Network Runtime设备接入指导](./example/drivers/README_zh.md)。
59
60## 相关仓
61
62- [neural_network_runtime](https://gitee.com/openharmony/neural_network_runtime)
63- [third_party_mindspore](https://gitee.com/openharmony/third_party_mindspore)
64