Huawei HiAI DDK User Manual
Issue: V100.150.12
Date: 2018-06-06
Huawei Technologies Co., Ltd.
2018-06-06
Huawei confidential. No spreading without permission.
Page 2 of 26
Copyright © Huawei Technologies Co., Ltd. 2018. All rights reserved.
No part of this document may be reproduced or transmitted in any form or by any means without prior written consent
of Huawei Technologies Co., Ltd.
Trademarks and Permissions
and other Huawei trademarks are trademarks of Huawei Technologies Co., Ltd.
All other trademarks and trade names mentioned in this document are the property of their respective holders.
Notice
The information in this document is subject to change without notice. Every effort has been made in the preparation of
this document to ensure accuracy of the contents, but all statements, information, and recommendations in this
document do not constitute a warranty of any kind, express or implied.
The method of applying for HiAI is described as follows:
1. Send an application email to developer@huawei.com.
2. The format of the email subject is HUAWEI HiAI+Company name+Product name.
3. The format of the email body is Cooperation company+Contact person+Contact information+Contact
email address.
4. We will send you feedback within five workdays after receiving your email.
Official website: http://developer.huawei.com/consumer/cn/devunion/ui/server/HiAI.html
2018-06-06
Huawei confidential. No spreading without permission.
Page 2 of 26
Change History
Date
Revision Version
Description
2018-03-09
V100.150.10
This is the initial draft.
2018-04-03
V100.150.11
The interface for obtaining the shape model is deleted.
2018-06-06
V100.150.12
The document structure is optimized, and the model
pre-processing information is added to describe online
compilation.
Huawei HiAI DDK User Manual
INTERNAL
2018-06-06
Huawei confidential. No spreading without permission.
Page 3 of 26
Contents
1 Overview ......................................................................................................................................... 5
2 DDK Description .......................................................................................................................... 5
2.1 App Source ....................................................................................................................................................... 5
2.2 DDK ................................................................................................................................................................. 6
2.3 Documents ....................................................................................................................................................... 7
2.4 Tools ................................................................................................................................................................. 7
3 Integration Overview ................................................................................................................... 7
4 Development Environment ......................................................................................................... 8
5 Supported Operators .................................................................................................................... 8
6 Restrictions ..................................................................................................................................... 8
7 Model Conversion......................................................................................................................... 8
7.1 Caffe Model Conversion .................................................................................................................................. 9
7.2 TensorFlow Model Conversion ........................................................................................................................ 9
7.2.1 Offline Model Generation ....................................................................................................................... 9
7.2.2 Model Parameter File ............................................................................................................................ 10
8 Model Integration ....................................................................................................................... 10
9 Supported Interfaces .................................................................................................................. 11
9.1 Obtaining the DDK Version Number ............................................................................................................. 11
9.2 Creating a Model Manager ............................................................................................................................. 11
9.2.1 Synchronization Interface ..................................................................................................................... 11
9.2.2 Asynchronization Interface ................................................................................................................... 13
9.3 Pre-Processing a Model .................................................................................................................................. 13
9.3.1 Creating the HIAI_MemBuffer ............................................................................................................. 14
9.3.2 Checking Compatibility ........................................................................................................................ 15
9.3.3 Compiling a Model ............................................................................................................................... 16
9.3.4 Exporting an Offline Model .................................................................................................................. 16
9.3.5 Destroying the HIAI_MemBuffer ......................................................................................................... 17
9.4 Loading a Model ............................................................................................................................................ 17
9.4.1 Creating the HIAI_ModelBuffer ........................................................................................................... 17
9.4.2 Model Loading ...................................................................................................................................... 18
9.4.3 Destroying the HIAI_ModelBuffer Interface ........................................................................................ 18
9.5 Running a Model ............................................................................................................................................ 19
9.5.1 Creating the HIAI_TensorBuffer Interface ........................................................................................... 19
9.5.2 Obtaining the Input or Output Data Address of a Model ...................................................................... 19
9.5.3 Obtaining the Data Length of Model Input or Output ........................................................................... 19
Huawei HiAI DDK User Manual
INTERNAL
2018-06-06
Huawei confidential. No spreading without permission.
Page 4 of 26
9.5.4 Running a Model ................................................................................................................................... 19
9.5.5 Destroying the HIAI_TensorBuffer ...................................................................................................... 20
9.6 Unloading a Model ......................................................................................................................................... 20
9.7 Destroying a Model Manager ......................................................................................................................... 21
10 Processing Offline Model Integration Compatibility ....................................................... 21
10.1 Using Model Preprocessing (Recommended). ............................................................................................. 21
10.2 Automatically Downloading an Offline Model Using the App .................................................................... 21
11 Q&A ............................................................................................................................................. 22
12 Appendix .................................................................................................................................... 23
12.1 Definition of Error Codes of Synchronous Interfaces .................................................................................. 23
12.2 Definition of Error Codes of Asynchronous Interfaces ................................................................................ 24