Unloading a Model
After model execution is complete, unload the model and deallocate model resources.
For details about the API call sequence, see AscendCL API Call Sequence.
Principles
After model inference is complete, unload the model by using the aclmdlUnload call, destroy the model description of the aclmdlDesc type, and free the workspace and weight memory for model execution.
Sample Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
//1. Unload the model. aclError ret = aclmdlUnload(modelId_); //2. Destroy the model description. if (modelDesc_ != nullptr) { (void)aclmdlDestroyDesc(modelDesc_); modelDesc_ = nullptr; } //3. Free the workspace for model execution. if (modelWorkPtr_ != nullptr) { (void)aclrtFree(modelWorkPtr_); modelWorkPtr_ = nullptr; modelWorkSize_ = 0; } //4. Free the weight memory for model execution. if (modelWeightPtr_ != nullptr) { (void)aclrtFree(modelWeightPtr_); modelWeightPtr_ = nullptr; modelWeightSize_ = 0; } |
Parent topic: Inference with Single-Batch and Static-Shape Inputs