Inference App Development Workflow
This section describes the process of developing a basic inference application based on AscendCL APIs.
- Set up the environment.
- Create code directories.
Create a directory to store code files, build scripts, test images, and model files.
The following is an example:
├App name ├── model // Model files │ ├── xxxxxx ├── data │ ├── xxx.jpg // Test data ├── inc // Header files that declare functions │ ├── xxx.h ├── out // Output files ├── src │ ├── xxx.json // Configuration files for system initialization │ ├── CMakeLists.txt // Build scripts │ ├── xxx.cpp // Implementation files
- Build a model.
For model inference, the offline model adapted to the Ascend AI Processor (.om file) is mandatory. For details, see Building a Model.
- Develop an app.
- Initialize AscendCL. For details, see Initializing AscendCL.
Before using the AscendCL APIs to develop an app, aclInit must be called to initialize AscendCL. Failure to do so may result in errors when internal resources are being initialized, which can then lead to service exceptions.
- Allocate runtime resources. For details, see Runtime Resource Allocation and Deallocation.
- Transfer data. For details, see Data Transfer.
- Run model inference. For details, see Inference with Single-Batch and Static-Shape Inputs.
Perform data postprocessing if required. For example, for an image classification app, you might need to identify the class indexes with the top confidence values.
After model inference is complete, destroy the allocations related to the inference.
- When data processing is complete, destroy runtime allocations. For details, see Runtime Resource Allocation and Deallocation.
- Deinitialize AscendCL. For details, see Initializing AscendCL.
- Initialize AscendCL. For details, see Initializing AscendCL.
- Build and run the app. This includes model conversion, code compilation, and app execution. For details, see App Build and Run