| 437 | } |
| 438 | } |
| 439 | ErrorCode StaticModule::_resize(const std::vector<Express::VARP>& inputs) { |
| 440 | ErrorCode code = NO_ERROR; |
| 441 | auto& pipelineInfo = mSession->getPipelineInfo(0); |
| 442 | auto rtmInside = mRuntimeManager->getInside(); |
| 443 | int curStatus = 0; |
| 444 | if (mResource->mModes.inputMode == Interpreter::Session_Input_User) { |
| 445 | pipelineInfo.first.inputBackendChange = false; |
| 446 | bool needResize = mResource->mUseContentInputs; |
| 447 | for (int i = 0; i < inputs.size(); ++i) { |
| 448 | if (nullptr == mInputTensors[i]) { |
| 449 | continue; |
| 450 | } |
| 451 | auto inputTensor = Utils::getTensor(inputs[i]); |
| 452 | Schedule::TENSORCACHE* cacheTensor = nullptr; |
| 453 | if (mPrevInputTensor[i].first != inputTensor) { |
| 454 | auto newBackend = TensorUtils::getDescribeOrigin(inputTensor)->getBackend(); |
| 455 | auto newType = MNN_FORWARD_CPU; |
| 456 | if (nullptr != newBackend) { |
| 457 | newType = newBackend->type(); |
| 458 | } |
| 459 | if (mPrevInputTensor[i].second != newType) { |
| 460 | pipelineInfo.first.inputBackendChange = true; |
| 461 | } |
| 462 | auto cacheIter = pipelineInfo.first.inputTensorCopyCache.find(mInputTensors[i]); |
| 463 | cacheTensor = &cacheIter->second; |
| 464 | MNN_ASSERT(cacheIter != pipelineInfo.first.inputTensorCopyCache.end()); |
| 465 | std::get<3>(cacheIter->second) = true; |
| 466 | mPrevInputTensor[i] = std::make_pair(inputTensor, newType); |
| 467 | if (std::get<1>(*cacheTensor) != nullptr) { |
| 468 | if (!WrapExecution::needWrap(inputTensor, TensorUtils::getDescribeOrigin(std::get<0>(*cacheTensor))->getBackend())) { |
| 469 | // No need copy now, reset it |
| 470 | cacheIter->second = std::make_tuple(nullptr, nullptr, true, true); |
| 471 | } |
| 472 | } |
| 473 | } |
| 474 | auto srcDes = TensorUtils::getDescribe(inputTensor); |
| 475 | auto des = TensorUtils::getDescribe(mInputTensors[i]); |
| 476 | bool needCopy = false; |
| 477 | if (nullptr != srcDes->quantAttr.get()) { |
| 478 | if (nullptr == des->quantAttr.get()) { |
| 479 | needCopy = true; |
| 480 | } |
| 481 | } |
| 482 | if (mResource->mInputNeedCPU[i]) { |
| 483 | if (0 != inputTensor->buffer().device) { |
| 484 | needCopy = true; |
| 485 | } |
| 486 | } |
| 487 | if (srcDes->tensorArrayAttr.get() != nullptr) { |
| 488 | // For tensorArray, don't need content |
| 489 | needCopy = false; |
| 490 | mSession->setNeedResize(); |
| 491 | } |
| 492 | bool needMalloc; |
| 493 | if (needCopy) { |
| 494 | auto srcPtr = (uint8_t*)inputs[i]->readMap<uint8_t>(); |
| 495 | needMalloc = mInputTensors[i]->buffer().host != srcPtr; |
| 496 | mInputTensors[i]->buffer().host = srcPtr; |
nothing calls this directly
no test coverage detected