| 270 | return true; |
| 271 | } |
| 272 | void StaticModule::resetInputOutputs() { |
| 273 | mPrevInputTensor.resize(mResource->mInputs.size()); |
| 274 | mInputTensors.resize(mResource->mInputs.size()); |
| 275 | auto& pipelineInfo = mSession->getPipelineInfo(0); |
| 276 | for (int i = 0; i < mResource->mInputs.size(); ++i) { |
| 277 | mInputTensors[i] = mSession->getTensor(mResource->mInputs[i]); |
| 278 | auto des = TensorUtils::getDescribe(mInputTensors[i]); |
| 279 | if (des->usage != Tensor::InsideDescribe::CONSTANT && des->usage != Tensor::InsideDescribe::TRAINABLE) { |
| 280 | des->usage = Tensor::InsideDescribe::INPUT; |
| 281 | } |
| 282 | pipelineInfo.first.inputTensorCopyCache.insert(std::make_pair(mInputTensors[i], std::make_tuple(nullptr, nullptr, true, true))); |
| 283 | mPrevInputTensor[i].first = nullptr; |
| 284 | mPrevInputTensor[i].second = MNN_FORWARD_CPU; |
| 285 | } |
| 286 | mOutputTensors.resize(mResource->mOutputFromTensor.size()); |
| 287 | for (int i = 0; i < mResource->mOutputFromTensor.size(); ++i) { |
| 288 | mOutputTensors[i] = mSession->getTensor(mResource->mOutputs[mResource->mOutputFromTensor[i]]); |
| 289 | auto des = TensorUtils::getDescribe(mOutputTensors[i]); |
| 290 | if (des->usage == Tensor::InsideDescribe::NORMAL) { |
| 291 | des->usage = Tensor::InsideDescribe::OUTPUT; |
| 292 | } |
| 293 | } |
| 294 | // Mask Geometry Compute Mid Tensor release able indexes |
| 295 | auto& infos = pipelineInfo; |
| 296 | for (auto& info : infos.second) { |
| 297 | info.releaseAbleInputs.clear(); |
| 298 | if (info.type != Schedule::Type::CONSTANT) { |
| 299 | continue; |
| 300 | } |
| 301 | for (auto t : info.inputs) { |
| 302 | auto des = TensorUtils::getDescribe(t); |
| 303 | if (des->usage == Tensor::InsideDescribe::CONSTANT && des->isMutable) { |
| 304 | des->useCount = 0; |
| 305 | } |
| 306 | } |
| 307 | } |
| 308 | for (auto& info : infos.second) { |
| 309 | for (auto t : info.inputs) { |
| 310 | auto des = TensorUtils::getDescribe(t); |
| 311 | if (des->usage == Tensor::InsideDescribe::CONSTANT && des->isMutable) { |
| 312 | des->useCount++; |
| 313 | } |
| 314 | } |
| 315 | } |
| 316 | for (int i = 0; i < mResource->mOutputFromTensor.size(); ++i) { |
| 317 | mOutputTensors[i] = mSession->getTensor(mResource->mOutputs[mResource->mOutputFromTensor[i]]); |
| 318 | auto des = TensorUtils::getDescribe(mOutputTensors[i]); |
| 319 | if (des->usage == Tensor::InsideDescribe::CONSTANT && des->isMutable) { |
| 320 | des->useCount ++; |
| 321 | } |
| 322 | } |
| 323 | for (auto& info : infos.second) { |
| 324 | if (info.type != Schedule::Type::CONSTANT) { |
| 325 | continue; |
| 326 | } |
| 327 | for (int v=0; v<info.inputs.size(); ++v) { |
| 328 | auto des = TensorUtils::getDescribe(info.inputs[v]); |
| 329 | if (des->usage == Tensor::InsideDescribe::CONSTANT && des->isMutable) { |