模型卸载
模型执行结束后,需及时卸载模型,释放模型资源。
关于模型卸载的接口调用流程,请先参见AscendCL接口调用流程了解整体流程,再查看本节中的流程说明。
示例代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 |
// 1. 卸载模型 aclError ret = aclmdlUnload(modelId_); // 2. 释放模型描述信息 if (modelDesc_ != nullptr) { (void)aclmdlDestroyDesc(modelDesc_); modelDesc_ = nullptr; } // 3. 释放模型运行的工作内存 if (modelWorkPtr_ != nullptr) { (void)aclrtFree(modelWorkPtr_); modelWorkPtr_ = nullptr; modelWorkSize_ = 0; } // 4. 释放模型运行的权值内存 if (modelWeightPtr_ != nullptr) { (void)aclrtFree(modelWeightPtr_); modelWeightPtr_ = nullptr; modelWeightSize_ = 0; } |
父主题: 单Batch&静态Shape输入推理