!17847 [LITE][convert] fix infershape of memcpy

From: @YeFeng_24
Reviewed-by: @hangangqiang,@zhanghaibo5
Signed-off-by: @hangangqiang
This commit is contained in:
mindspore-ci-bot 2021-06-07 09:29:23 +08:00 committed by Gitee
commit 8cb0a4c8e9
1 changed files with 6 additions and 4 deletions

View File

@ -40,6 +40,7 @@ void FreeTensors(std::vector<Tensor *> *input_tensors, std::vector<Tensor *> *ou
return; return;
} }
for (auto &tensor : *input_tensors) { for (auto &tensor : *input_tensors) {
tensor->set_data(nullptr);
delete tensor; delete tensor;
tensor = nullptr; tensor = nullptr;
} }
@ -47,6 +48,7 @@ void FreeTensors(std::vector<Tensor *> *input_tensors, std::vector<Tensor *> *ou
return; return;
} }
for (auto &tensor : *output_tensors) { for (auto &tensor : *output_tensors) {
tensor->set_data(nullptr);
delete tensor; delete tensor;
tensor = nullptr; tensor = nullptr;
} }
@ -134,10 +136,10 @@ void ConvertOtherTensor(MetaGraphT *graph, uint32_t index, bool *convert_succ, s
*convert_succ = false; *convert_succ = false;
return; return;
} }
if (memcpy_s(lite_tensor->data_c(), lite_tensor->Size(), tensorT->data.data(), tensorT->data.size()) != EOK) { if (lite_tensor->root_tensor() != nullptr) {
MS_LOG(ERROR) << "memcpy_s failed"; lite_tensor->root_tensor()->set_data(tensorT->data.data());
*convert_succ = false; } else {
return; lite_tensor->set_data(tensorT->data.data());
} }
lite_tensors->emplace_back(lite_tensor.release()); lite_tensors->emplace_back(lite_tensor.release());
} }