Typical API Calls
The API calling flowchart describes the typical API calls. If the size of the input image does not meet the model requirements, data preprocessing is required. To implement model inference, the model needs to be loaded first. After the completion of model inference, the model needs to be unloaded. After model inference, the inference result needs to be postprocessed for looking up the class indexes with the top confidence values.
- ACL initialization: Call acl.init to initialize the ACL.
- Runtime resource allocation: Allocate devices, contexts, and streams in sequence. For details, see Runtime Resource Allocation.
- Operator calling. For details, see Operator Calling.
- Operator .om file generation: Build the .json definition file into an .om offline model adapted to Ascend AI Processors with the ATC. For details, see ATC Tool Instructions.
- Operator .om file loading for operator running.
- Operator execution for result output
- Model inference
- Model .om file generation: Convert the third-party network (for example, Caffe ResNet-50) into an offline model (.om file) that adapts to Ascend AI Processors with the ATC. For details, see ATC Tool Instructions.
- Model loading: Load the model to the system for model inference. For details, see Model Loading.
- (Optional) Data preprocessing: Implement JPEG image decoding, video decoding, image cropping, resizing and format conversion, as well as JPEG image encoding and video decoding. For details, see Data Preprocessing.
- Model inference: Implement object recognition and image classification with a model. Currently, the ACL provides synchronous and asynchronous inference APIs, supporting dynamic batch/image size, and dynamic AIPP scenarios. For details, see Model Inference.
- (Optional) Data postprocessing: Post-process the model inference result as required. For example, you can export the inference result to a file, and look up in the inference result for the class with the highest confidence score using single operators.
- Model unloading: Call acl.mdl.unload to unload a model.
- Runtime resource release: Release streams, contexts, and devices in sequence. For details, see Runtime Resource Release.
- ACL deinitialization: Call acl.finalize to deinitialize the ACL.
Memory allocation and release, data transfer (by memory copy), and data type creation and destruction are the most frequently-used calls in each phase of the application development, and therefore are not thoroughly illustrated in the flowchart. For details, see Memory Management.