HMS Toolkit supports converting MindSpore Lite and HUAWEI HiAI models. MindSpore Lite supports TensorFlow Lite and Caffe, and HiAI supports TensorFlow, Caffe, CoreML, PaddlePaddle, ONNX, MxNet, and Keras. HUAWEI HiAI Foundation integrates functions such as model conversion (containerization) environment detection, AI model analysis, AI model conversion, automatic generation of reference APIs, and dependency adding, helping you quickly integrate your own AI models.
MindSpore Lite Model Conversion
- Go to HMS > Coding Assistant > AI > Model Integration.
- Set basic information about MindSpore Lite model conversion. The details are described as follows:
- Inference engine: Select MindSpore Lite.
- Choose AI Model File: Select the MindSpore Lite model file to be converted. The TensorFlow Lite and Caffe frameworks are supported.
- Choose Prototxt File: Select the prototxt file corresponding to the Caffe framework. This parameter is automatically set when the Caffe model file is selected.
- Model output directory: Specify the storage directory for the new model created after conversion. By default, the new model is stored in the assets directory of the project.
- Choose the path of the generation model API file: Specify the storage directory for the API source file generated after conversion. Retain the default value.
- Quant Type: Select the quantization-aware training model for the TensorFlow Lite file. You can determine whether to support the quantization-aware training based on the model file.
- After the information is configured, click Finish and wait until the model conversion is complete. After the conversion is complete, click MindSpore Lite model for inference in the log bar to view the detailed integration guide.
If you use the MindSpore Lite model conversion function for the first time, the system will prompt you to download the MindSpore conversion tool.

HUAWEI HiAI Model Conversion
[h2]Prerequisites
- Docker Toolbox is installed.
- The model file to be converted is available.
[h2]TensorFlow Model Conversion
- Run Docker Desktop. If your network requires a proxy server to access the Internet, go to Settings > Proxies and set the Docker proxy. The proxy format is as follows: username:password@proxyserver:port.
If your network does not require a proxy server but can access the Internet, run Docker Desktop.
If your network is controlled and cannot access the Internet, you need to set the Docker proxy.

- Go to HMS > Coding Assistant > AI > Model Integration.
- Set basic information about TensorFlow model conversion. The details are described as follows:
- Inference engine: Select a DDK version based on the applicable Kirin chipset model.
DDK Version | Supports TensorFlow | TensorFlow Version | Chipset Model | Supported Operator |
HiAI DDK V150 | Supported | 1.4 or earlier | Kirin 970 | For details, please refer to the HUAWEI HiAI DDK Vxxx Operator Specifications, which can be obtained from the HUAWEI HiAI SDK package. |
HiAI DDK V200 | Supported | 1.12 or earlier | Kirin 980 |
HiAI DDK V300 | Supported | 1.12 or later | Kirin 810, Kirin 820, Kirin 985, and Kirin 990 |
HiAI DDK V310 | Supported | 1.12 or later |
HiAI DDK V320 | Supported | 1.12 or later |
- Choose AI Model File: Select the TensorFlow model file to be converted.
- Model output directory: Specify the storage directory for the new model created after conversion. By default, the new model is stored in the assets directory of the project.
- Choose the path of the generation model API file: Specify the storage directory for the API source file generated after conversion. Retain the default value.
- Weight Data Type: Specify the weight data type. The value can be FP32 or FP16. This parameter takes effect only when the existing weight is of the FP32 type. If the value is FP32, the weight is converted from FP32 to FP16. If the value is FP32, the data type of the weight is retained.
- Click Next and configure node information.
- Input Node: Specify the neural network input node.
- Output Node: Specify the neural network output node.
- Configure information in Image Preprocess.
- Input Node Name: The value is automatically generated based on the value of Input Node.
- Enable Config: For details about how to set the parameter, please refer to the HUAWEI HiAI DDK Vxxx OMG User Guide, which can be obtained from the HUAWEI HiAI SDK package.
- When you complete the settings, click Finish to start model conversion.
- HMS Toolkit will check the local environment where model conversion is conducted. If any problems are detected, a message will be displayed on the page, asking you to rectify them as prompted.
If the Check The Docker Image item fails, which is frequently encountered in environment checks, manually download Docker images, and perform operations as prompted. To download Docker images, use either of the following methods:
- In the Event Log area, click Install Images.

- On the page, click docker pull xxx to download it.

- If the message in red is displayed, modify the model based on the error log and start conversion again.

- During AI model conversion, HMS Toolkit converts your AI model into HUAWEI HiAI format. After the conversion is complete, the API class referenced by the model is automatically generated in the project directory and related dependencies are added. The following figure shows the files added after the conversion.

- Call the encapsulated APIs in the generated Java file [Model name]Model.java to run the converted model. In general cases, call Load then Predict. Both types provide synchronous and asynchronous APIs. Call the APIs based on your app's code logic.
The synchronous and asynchronous APIs of the Load type are as follows:
- Synchronization API: ArrayList<ModelInfo> loadSync()
- Asynchronous API: ArrayList<ModelInfo> loadAsync()
The synchronous and asynchronous APIs of the
Predict type are as follows:
- Synchronization API: predictSync(ArrayList<byte[]> buf)
- Asynchronous API: predictAsync(ArrayList<byte[]> buf)
[h2]Caffe Model Conversion
- Set the parameters related to Caffe model conversion. The details are described as follows:
- Inference engine: Select a DDK version based on the applicable Kirin chipset model.
DDK Version | Supports Caffe | Caffe Version | Chipset Model | Supported Operator |
HiAI DDK V150 | Supported | 1.0 | Kirin 970 | For details, please refer to the HUAWEI HiAI DDK Vxxx Operator Specifications, which can be obtained from the HUAWEI HiAI SDK package. |
HiAI DDK V200 | Supported | 1.0 | Kirin 980 |
HiAI DDK V300 | Supported | 1.0 | Kirin 810, Kirin 820, Kirin 985, and Kirin 990 |
HiAI DDK V310 | Supported | 1.0 |
HiAI DDK V320 | Supported | 1.0 |
- Choose AI Model File: Select the Caffe model file to be converted.
- Choose Prototxt: Select the prototxt file corresponding to the Caffe model. This parameter is automatically set when the Caffe model file is selected.
- Model output directory: Specify the storage directory for the new model created after conversion. By default, the new model is stored in the assets directory of the project.
- Choose the path of the generation model API file: Specify the storage directory for the API source file generated after conversion. Retain the default value.
For details about how to set the preceding parameters, please refer to the HUAWEI HiAI DDK Vxxx OMG User Guide, which can be obtained from the HUAWEI HiAI SDK package.
- Click Next and configure node information. By default, Config is disabled. You can manually enable it.
- Input Node: Specify the neural network input node.
- Output Node: Specify the neural network output node.
- Configure information in Image Preprocess.
- Input Node Name: The value is automatically generated based on the value of Input Node.
- Enable Config: For details about how to set the parameter, please refer to the HUAWEI HiAI DDK Vxxx OMG User Guide, which can be obtained from the HUAWEI HiAI SDK package.
- When you complete the settings, click Finish to start model conversion.
- HMS Toolkit will check the local environment where model conversion is conducted. If any problems are detected, a message will be displayed on the page, asking you to rectify them as prompted.
If the Check The Docker Image item fails, which is frequently encountered in environment checks, manually download Docker images, and perform operations as prompted. To download Docker images, use either of the following methods:
- In the Event Log area, click Install Images.

- On the page, click docker pull xxx to download it.

- If the message in red is displayed, modify the model based on the error log and start conversion again.

- During AI model conversion, HMS Toolkit converts your AI model into HUAWEI HiAI format. After the conversion is complete, the API class referenced by the model is automatically generated in the project directory and related dependencies are added. The following figure shows the files added after the conversion.

- Call the encapsulated APIs in the generated Java file [Model name]Model.java to run the converted model. In general cases, call Load then Predict. Both types provide synchronous and asynchronous APIs. Call the APIs based on your app's code logic.
The synchronous and asynchronous APIs of the Load type are as follows:
- Synchronization API: ArrayList<ModelInfo> loadSync()
- Asynchronous API: ArrayList<ModelInfo> loadAsync()
The synchronous and asynchronous APIs of the
Predict type are as follows:
- Synchronization API: predictSync(ArrayList<byte[]> buf)
- Asynchronous API: predictAsync(ArrayList<byte[]> buf)
[h2]Other Model Conversion
In addition to typical TensorFlow and Caffe models, HUAWEI HiAI Foundation also supports local conversion of CoreML, PaddlePaddle, Mxnet, Onnx, and Keras models. The conversion method is the same as that of the TensorFlow model. For details, please refer to TensorFlow Model Conversion. The following table lists the model support of each HUAWEI HiAI Foundation DDK version.
DDK Version | CoreML | PaddlePaddle | Mxnet | Onnx | Keras | TensorFlow Lite |
HiAI DDK 150 | Supported | Supported | Supported | Supported | Supported | Not supported |
HiAI DDK 200 | Supported | Supported | Supported | Supported | Supported | Not supported |
HiAI DDK 300 | Supported | Supported | Not supported | Not supported | Not supported | Not supported |
HiAI DDK 310 | Supported | Supported | Not supported | Not supported | Not supported | Not supported |
HiAI DDK 320 | Supported | Supported | Not supported | Not supported | Not supported | Not supported |
When the DDK version is MindSpore, the TensorFlow Lite model can be converted only in Windows. You need to download the MindSpore tool as prompted for the conversion.