diff --git a/mindspore/lite/src/lite_session.cc b/mindspore/lite/src/lite_session.cc index 6fa10cbef3..b499d18771 100644 --- a/mindspore/lite/src/lite_session.cc +++ b/mindspore/lite/src/lite_session.cc @@ -455,7 +455,7 @@ int LiteSession::ResizeInputs(const std::vector & MS_LOG(ERROR) << "Input[" << i << "] tensor is not equal to the inputs have been saved!"; return RET_PARAM_INVALID; } - + inputs_[i]->FreeData(); inputs_[i]->set_shape(dims[i]); } return RET_OK; @@ -463,6 +463,7 @@ int LiteSession::ResizeInputs(const std::vector & void LiteSession::ResetInputsShape(const std::vector> &dims) { for (size_t i = 0; i < inputs_.size(); ++i) { + inputs_[i]->FreeData(); inputs_[i]->set_shape(dims[i]); } } diff --git a/mindspore/lite/src/scheduler.cc b/mindspore/lite/src/scheduler.cc index 49b712ab8d..44e9b39843 100644 --- a/mindspore/lite/src/scheduler.cc +++ b/mindspore/lite/src/scheduler.cc @@ -66,6 +66,9 @@ int Scheduler::ReSizeKernels(const std::vector &kernels) { } std::vector &inputs = kernels[i]->in_tensors(); std::vector &outputs = kernels[i]->out_tensors(); + for (size_t j = 0; j < outputs.size(); j++) { + outputs[j]->FreeData(); + } primitive->SetInferFlag(!infer_shape_interrupt); auto ret = primitive->InferShape(inputs, outputs); if (ret == RET_INFER_INVALID) {