未验证 提交 7e92cc7f 编写于 作者: Q Qi Li 提交者: GitHub

fix model re-run error, test=develop (#4075)

上级 e97d9ad3
......@@ -249,6 +249,10 @@ bool AclModelClient::ModelExecute(
VLOG(3) << "[HUAWEI_ASCEND_NPU] GetTensorFromDataset succeed, modelId:"
<< model_id_;
// destroy dataset
DestroyDataset(&input_dataset_);
DestroyDataset(&output_dataset_);
return true;
}
......@@ -275,16 +279,13 @@ void AclModelClient::DestroyDataset(aclmdlDataset** dataset) {
VLOG(3) << "[HUAWEI_ASCEND_NPU] Destroy dataset success.";
}
bool AclModelClient::UnloadModel() {
void AclModelClient::UnloadModel() {
if (!load_flag_) {
LOG(WARNING) << "[HUAWEI_ASCEND_NPU] no need to unload model, load flag is "
<< load_flag_;
return true;
return;
}
DestroyDataset(&input_dataset_);
DestroyDataset(&output_dataset_);
ACL_CALL(aclmdlUnload(model_id_));
if (model_desc_ != nullptr) {
ACL_CALL(aclmdlDestroyDesc(model_desc_));
......@@ -304,7 +305,6 @@ bool AclModelClient::UnloadModel() {
}
load_flag_ = false;
VLOG(3) << "[HUAWEI_ASCEND_NPU] Unload model success, model id " << model_id_;
return true;
}
uint32_t AclModelClient::num_devices() {
......
......@@ -150,6 +150,9 @@ class AclModelClient {
}
~AclModelClient() {
VLOG(3) << "[HUAWEI_ASCEND_NPU] Unloading model, model id is: "
<< model_id_;
UnloadModel();
VLOG(3) << "[HUAWEI_ASCEND_NPU] Destroying Huawei Ascend Device: "
<< device_id_;
ACL_CALL(aclrtResetDevice(device_id_));
......@@ -161,7 +164,6 @@ class AclModelClient {
std::vector<TensorDesc>* output_tensor);
bool ModelExecute(std::vector<std::shared_ptr<ge::Tensor>>* input_tensor,
std::vector<std::shared_ptr<ge::Tensor>>* output_tensor);
bool UnloadModel();
private:
void CreateInputDataset(
......@@ -171,6 +173,7 @@ class AclModelClient {
bool GetTensorFromDataset(
std::vector<std::shared_ptr<ge::Tensor>>* output_tensor);
void DestroyDataset(aclmdlDataset** dataset);
void UnloadModel();
private:
uint32_t num_devices();
......
......@@ -304,8 +304,6 @@ bool DeviceProgram::SharedBufferWithOutputTensors(
(*origin_otensors)[i]->ResetBuffer(buffer,
(*device_otensors)[i]->GetSize());
}
// unload model after model execution
CHECK_EQ(model_client_->UnloadModel(), true);
return true;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册