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

Method _run

test/expr/ModuleTest.cpp:658–768  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

656class SessionCircleTest : public MNNTestCase {
657public:
658 bool _run(int precision, bool loop) {
659 int channel = 10;
660 flatbuffers::FlatBufferBuilder builderOutput(1024);
661 {
662 auto x = _Input({2, channel, 1, 1}, NC4HW4);
663 x->setName("x");
664 auto ox = x * x;
665 ox->setName("ox");
666 auto y = _Const(1.0f, {1, channel, 1, 1}, NC4HW4);
667 y->setName("y");
668 y.fix(VARP::TRAINABLE);
669 auto z = x * y;
670 z->setName("xy");
671 z = _ReduceMean(z);
672 z->setName("l");
673 z = y + z;
674 z = _Convert(z, NCHW);
675 z = _Unsqueeze(z, {0});
676 z = _Squeeze(z, {0});
677 z = _Convert(z, NC4HW4);
678 z->setName("z");
679 std::unique_ptr<MNN::NetT> net(new NetT);
680 Variable::save({z, ox}, net.get());
681 z = nullptr;
682 if (loop) {
683 // Make Loop
684 // Find x index
685 int yIndex = -1;
686 int zIndex = -1;
687 for (int i=0; i<net->tensorName.size(); ++i) {
688 if (net->tensorName[i] == "y") {
689 yIndex = i;
690 } else if (net->tensorName[i] == "z") {
691 zIndex = i;
692 }
693 }
694 if (yIndex == -1 || zIndex == -1) {
695 FUNC_PRINT(1);
696 return false;
697 }
698 for (auto& op : net->oplists) {
699 for (int i=0; i<op->outputIndexes.size(); ++i) {
700 if (op->outputIndexes[i] == zIndex) {
701 op->outputIndexes[i] = yIndex;
702 }
703 }
704 }
705 }
706 auto len = MNN::Net::Pack(builderOutput, net.get());
707 builderOutput.Finish(len);
708 }
709 int sizeOutput = builderOutput.GetSize();
710 auto bufferOutput = builderOutput.GetBufferPointer();
711 std::shared_ptr<Interpreter> net(Interpreter::createFromBuffer((void*)bufferOutput, sizeOutput), Interpreter::destroy);
712 auto rt = MNN::Express::Executor::getGlobalExecutor()->getRuntime().first;
713 auto type = MNN_FORWARD_CPU;
714 for (auto& iter : rt) {
715 if (iter.first != MNN_FORWARD_CPU) {

Callers

nothing calls this directly

Calls 15

_InputFunction · 0.85
_ConstFunction · 0.85
_ReduceMeanFunction · 0.85
_ConvertFunction · 0.85
_UnsqueezeFunction · 0.85
_SqueezeFunction · 0.85
fixMethod · 0.80
setSessionModeMethod · 0.80
getSessionInputMethod · 0.80
getSessionOutputMethod · 0.80
resizeTensorMethod · 0.80
resizeSessionMethod · 0.80

Tested by

no test coverage detected