qqc1989 commited on
Commit
ddbb832
·
verified ·
1 Parent(s): ccba218

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +125 -3
README.md CHANGED
@@ -1,3 +1,125 @@
1
- ---
2
- license: mit
3
- ---
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: mit
3
+ language:
4
+ - en
5
+ tags:
6
+ - ONNX
7
+ - ONNXRUNTIME
8
+ - AXEngine
9
+ ---
10
+
11
+ ## 简介
12
+
13
+ **PyAXEngine** 基于 cffi 模块实现了 Axera NPU Runtime 的 Python API,其 Python API 与 ONNXRuntime 高度兼(相)容(似),并同时支持开发板和M.2算力卡形态,方便开源社区开发者使用
14
+ Python 脚本快速构建 NPU 推理脚本
15
+
16
+ 支持芯片
17
+
18
+ - AX650N
19
+ - AX630C
20
+
21
+ 环境版本
22
+
23
+ - python >= 3.8
24
+ - cffi >= 1.0.0
25
+ - ml-dtypes >= 0.1.0
26
+ - numpy >= 1.22.0
27
+
28
+ *需要注意的是,如果您的开发环境是算力卡,那么更建议您优先考虑使用 [pyAXCL](https://github.com/AXERA-TECH/pyaxcl) 进行项目开发;pyAXCL 项目完整包含了算力卡形态的全部 API,更适合用于正式部署;PyAXEngine 项目更适合算法工程师进行快速原型验证,且用于计算卡环境时,PyAXEngine 不能调用编解码等模块(不是 PyAXEngine 的设计目标)。*
29
+
30
+ *AX650 SDK 2.18,AX620E SDK 3.12 以前的版本不支持 bf16,llm 模型会有返回 unknown 的 dtype问题,请注意升级*
31
+
32
+ *如果您评估认为不知道如何升级 SDK,也可以提交 issue 索要下载,不需要更新完整 SDK,只更新 libax_engine.so 即可*
33
+
34
+ ## 快速上手
35
+
36
+ 基于社区开发板 **爱芯派Pro(AX650N)** 进行展示
37
+
38
+ ### 获取 wheel 包并安装
39
+
40
+ - [下载链接](https://github.com/AXERA-TECH/pyaxengine/releases/latest)
41
+ - 将 `axengine-x.x.x-py3-none-any.whl` 拷贝到开发板上,执行 `pip install axengine-x.x.x-py3-none-any.whl` 安装
42
+
43
+ ### 简单示例
44
+
45
+ 当前示例需要分别依赖 PIL 和 OpenCV,可以用 `pip install pillow opencv-python-headless` 安装。其中 `opencv-python-headless` 是 OpenCV 的 headless 版本,不依赖 GUI(非 headless 的版本需要依赖 OpenGL ES,运行环境中并没有)。
46
+
47
+ ```python
48
+ 将 [classification.py](https://github.com/AXERA-TECH/pyaxengine/blob/main/examples/classification.py) 拷贝到开发板上并执行。
49
+
50
+ ```bash
51
+ root@ax650:~/samples# python3 classification.py -m /opt/data/npu/models/mobilenetv2.axmodel -i /opt/data/npu/images/cat.jpg
52
+ [INFO] Available providers: ['AXCLRTExecutionProvider', 'AxEngineExecutionProvider']
53
+ [INFO] Using provider: AxEngineExecutionProvider
54
+ [INFO] Chip type: ChipType.MC50
55
+ [INFO] VNPU type: VNPUType.DISABLED
56
+ [INFO] Engine version: 2.10.1s
57
+ [INFO] Model type: 0 (single core)
58
+ [INFO] Compiler version: 1.2-patch2 7e6b2b5f
59
+ ------------------------------------------------------
60
+ Top 5 Predictions:
61
+ Class Index: 282, Score: 9.774
62
+ Class Index: 278, Score: 8.981
63
+ Class Index: 277, Score: 8.453
64
+ Class Index: 281, Score: 8.321
65
+ Class Index: 287, Score: 7.924
66
+ ------------------------------------------------------
67
+ min = 0.890 ms max = 22.417 ms avg = 1.119 ms
68
+ ------------------------------------------------------
69
+ ```
70
+
71
+ 示例也演示了如何选择计算设备:这意味着既可以在 **AX650/AX630C** 等开发板上运行,也可以在 AX650 M.2 算力卡上运行。
72
+
73
+ 切换计算设备的方式是通过 `-p` 参数指定,如 `-p AxEngineExecutionProvider` 表示使用开发板上的 NPU 进行推理,而 `-p AXCLRTExecutionProvider` 表示使用 M.2 算力卡进行推理。
74
+ 注意:在使用 M.2 算力卡进行推理时,需要将算力卡插入宿主机上,并且已经安装驱动,详见: [axcl](https://axcl-docs.readthedocs.io/zh-cn/latest/)。
75
+
76
+ ```bash
77
+ root@ax650:~/samples# python3 classification.py -m /opt/data/npu/models/mobilenetv2.axmodel -i /opt/data/npu/images/cat.jpg -p AXCLRTExecutionProvider
78
+ [INFO] Available providers: ['AXCLRTExecutionProvider', 'AxEngineExecutionProvider']
79
+ [INFO] Using provider: AXCLRTExecutionProvider
80
+ [INFO] SOC Name: AX650N
81
+ [INFO] VNPU type: VNPUType.DISABLED
82
+ [INFO] Compiler version: 1.2-patch2 7e6b2b5f
83
+ ------------------------------------------------------
84
+ Top 5 Predictions:
85
+ Class Index: 282, Score: 9.774
86
+ Class Index: 278, Score: 8.981
87
+ Class Index: 277, Score: 8.453
88
+ Class Index: 281, Score: 8.321
89
+ Class Index: 287, Score: 7.924
90
+ ------------------------------------------------------
91
+ min = 1.587 ms max = 12.624 ms avg = 1.718 ms
92
+ ------------------------------------------------------
93
+ root@ax650:~/samples# python3 classification.py -m /opt/data/npu/models/mobilenetv2.axmodel -i /opt/data/npu/images/cat.jpg -p AxEngineExecutionProvider
94
+ [INFO] Available providers: ['AXCLRTExecutionProvider', 'AxEngineExecutionProvider']
95
+ [INFO] Using provider: AxEngineExecutionProvider
96
+ [INFO] Chip type: ChipType.MC50
97
+ [INFO] VNPU type: VNPUType.DISABLED
98
+ [INFO] Engine version: 2.10.1s
99
+ [INFO] Model type: 0 (single core)
100
+ [INFO] Compiler version: 1.2-patch2 7e6b2b5f
101
+ ------------------------------------------------------
102
+ Top 5 Predictions:
103
+ Class Index: 282, Score: 9.774
104
+ Class Index: 278, Score: 8.981
105
+ Class Index: 277, Score: 8.453
106
+ Class Index: 281, Score: 8.321
107
+ Class Index: 287, Score: 7.924
108
+ ------------------------------------------------------
109
+ min = 0.897 ms max = 22.542 ms avg = 1.125 ms
110
+ ------------------------------------------------------
111
+ ```
112
+
113
+ ## 社区贡献者
114
+
115
+ - [zylo117](https://github.com/zylo117): 提供了基于 cffi 的 AXCL Runtime Python API 实现
116
+ - [nnn](https://github.com/nnn112358),[HongJie Li](https://github.com/techshoww) 和 [Shinichi Tanaka](https://github.com/s1tnk) 报告 cffi 的使用问题,[Shinichi Tanaka](https://github.com/s1tnk) 提供了解决方案
117
+
118
+
119
+ ## 关联项目
120
+
121
+ - [ax-samples](https://github.com/AXERA-TECH/ax-samples)
122
+ - [ax-llm](https://github.com/AXERA-TECH/ax-llm)
123
+ - [Pulsar2](https://pulsar2-docs.readthedocs.io/zh-cn/latest/)
124
+ - [AXCL](https://axcl-docs.readthedocs.io/zh-cn/latest/)
125
+ - [pyAXCL](https://github.com/AXERA-TECH/pyaxcl)