diff --git a/mobile/src/framework/executor.cpp b/mobile/src/framework/executor.cpp index 169ab63307b37af89e4c19a7dcb41d4b640d3db5..d03cefe59a221093d4e5fb4e86273b3007097d9f 100644 --- a/mobile/src/framework/executor.cpp +++ b/mobile/src/framework/executor.cpp @@ -363,7 +363,10 @@ void Executor::InitNoPersistableMemory(const Tensor &input_tensor) { DLOG << "InitNoPersistableMemory var " << var_desc->Name(); auto tensor = var->template GetMutable(); if (tensor->IsInitialized() && tensor->dims().size() == 4) { - DLOG << "var's tensor is Initialized or dims size != 4"; + // don't change user's input and avoid memory leaks + if (feed_indices_.find(var_desc->Name()) != feed_indices_.end()) { + break; + } DDim tensor_dim = tensor->dims(); DDim new_dim = make_ddim({tensor_dim[0], tensor_dim[1], input_tensor.dims()[2],