It is not yet supported to directly run networks trained under open-source frameworks (such as Caffe and TensorFlow) on Ascend AI Processor. ATC is provided to convert such a network into an offline model adapted to the Ascend AI Processor (.om file).
The following uses the ResNet-50 network under the Caffe framework as an example to describe how to use ATC to convert a model. For details, see ATC Instructions.
- Obtain a Caffe network model.
Download the .prototxt model file and .caffemodel weight file of the ResNet-50 network and upload the files to any directory in the development environment as the CANN running user, for example, $HOME/module/.
- ResNet-50 network model file (*.prototxt): Click here to download the file.
- ResNet-50 weight file (*.caffemodel): Click here to download the file.
- Run the following command to generate an offline model. (The path and file arguments are for reference only).
atc --model=$HOME/module/resnet50.prototxt --weight=$HOME/module/resnet50.caffemodel --framework=0 --output=$HOME/module/out/caffe_resnet50 --soc_version=<soc_version>
The key parameters are described as follows:
- Check that your model is converted successfully.
ATC run success
Find the generated offline model (for example, caffe_resnet50.om) in the directory specified by the --output argument.
- (Follow-up) If you want to run inference on the generated offline model, prepare the environment, .om file, and input data in .bin format that meets the model input requirements, and then run the msame tool. Click here to obtain the msame tool, and refer to the readme file for instructions.
- During model conversion, if a message is displayed indicating that some operators are not supported, develop custom operators first by referring to Operator Developer Guide, and then convert the model again.
- During model conversion, if a message is displayed, indicating that an operator compilation error occurs, but the message cannot help you locate the error, contact Huawei technical support. You need to set the DUMP_GE_GRAPH and DUMP_GRAPH_LEVEL environment variables, convert your model again, and dump graphs in each phase during model conversion. For details about the environment variables and dump graphs, see "See Also > Dump Graph Details" in ATC Instructions.
- For details about the building and inference of models with a dynamic input shape, see Model Inference with Dynamic-Shape Inputs.
- If image preprocessing is performed on the AI Core by using dynamic AIPP, including image resizing, CSC, and mean value subtraction and factor multiplication (for pixel changing), see Dynamic AIPP Model Inference to learn about model building and inference.
- If the existing network does not meet your requirements, you can use the operators supported by Ascend AI Processor and call Ascend Graph APIs to build your own network, and then compile the network into an .om file. For details, see Ascend Graph Developer Guide.