MCPcopy Create free account
hub / github.com/alibaba/MNN / _SetTensorBackend

Function _SetTensorBackend

source/core/Pipeline.cpp:621–683  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

619 return NO_ERROR;
620}
621static 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);

Callers 1

allocMemoryMethod · 0.85

Calls 6

setBackendMethod · 0.80
sizeMethod · 0.45
typeMethod · 0.45
backendMethod · 0.45
getMethod · 0.45
getBackendMethod · 0.45

Tested by

no test coverage detected