| 619 | return NO_ERROR; |
| 620 | } |
| 621 | static void _SetTensorBackend(Schedule::PipelineInfo& mInfo, bool ownInputs) { |
| 622 | // Clear Valid Tensor's Backend |
| 623 | for (int infoIndex=0; infoIndex < mInfo.second.size(); ++infoIndex) { |
| 624 | auto& info = mInfo.second[infoIndex]; |
| 625 | if (info.type == Schedule::CONSTANT) { |
| 626 | continue; |
| 627 | } |
| 628 | auto& buffer = info.executeBuffer; |
| 629 | // MNN_PRINT("before resize, mInfo.second size:%lu, command size:%lu,op type:%s, op name:%s\n", mInfo.second.size(), buffer.command.size(), EnumNameOpType(info.op->type()), info.op->name()->c_str()); |
| 630 | for (int iterIndex=0; iterIndex<buffer.command.size(); ++iterIndex) { |
| 631 | auto& iterP = buffer.command[iterIndex]; |
| 632 | auto& iter = *iterP; |
| 633 | if (iter.op->type() == OpType_Copy) { |
| 634 | continue; |
| 635 | } |
| 636 | auto curBackend = iter.execution->backend(); |
| 637 | if (ownInputs) { |
| 638 | for (auto t : iter.inputs) { |
| 639 | auto des = TensorUtils::getDescribeOrigin(t); |
| 640 | if (nullptr == des->mem.get()) { |
| 641 | des->setBackend(nullptr); |
| 642 | } |
| 643 | } |
| 644 | } |
| 645 | for (auto t : iter.outputs) { |
| 646 | auto des = TensorUtils::getDescribeOrigin(t); |
| 647 | if (nullptr == des->mem.get()) { |
| 648 | des->setBackend(nullptr); |
| 649 | } |
| 650 | } |
| 651 | } |
| 652 | } |
| 653 | |
| 654 | // Set Tensor's Backend |
| 655 | for (auto& info : mInfo.second) { |
| 656 | if (info.type == Schedule::CONSTANT) { |
| 657 | continue; |
| 658 | } |
| 659 | auto& buffer = info.executeBuffer; |
| 660 | // MNN_PRINT("before resize, mInfo.second size:%lu, command size:%lu,op type:%s, op name:%s\n", mInfo.second.size(), buffer.command.size(), EnumNameOpType(info.op->type()), info.op->name()->c_str()); |
| 661 | for (auto& iterP : buffer.command) { |
| 662 | auto& iter = *iterP; |
| 663 | if (iter.op->type() == OpType_Copy) { |
| 664 | continue; |
| 665 | } |
| 666 | auto curBackend = iter.execution->backend(); |
| 667 | if (ownInputs) { |
| 668 | for (auto t : iter.inputs) { |
| 669 | auto des = TensorUtils::getDescribeOrigin(t); |
| 670 | if (nullptr == des->mem.get() && nullptr == des->getBackend()) { |
| 671 | des->setBackend(curBackend); |
| 672 | } |
| 673 | } |
| 674 | } |
| 675 | for (auto t : iter.outputs) { |
| 676 | auto des = TensorUtils::getDescribeOrigin(t); |
| 677 | if (nullptr == des->mem.get() && nullptr == des->getBackend()) { |
| 678 | des->setBackend(curBackend); |
no test coverage detected