| 656 | class SessionCircleTest : public MNNTestCase { |
| 657 | public: |
| 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) { |
nothing calls this directly
no test coverage detected