| 780 | class SessionTest : public MNNTestCase { |
| 781 | public: |
| 782 | bool _run(int precision, bool lazy) { |
| 783 | flatbuffers::FlatBufferBuilder builderOutput(1024); |
| 784 | { |
| 785 | auto y = _mobileNetV1Expr(); |
| 786 | std::unique_ptr<MNN::NetT> net(new NetT); |
| 787 | Variable::save({y}, net.get()); |
| 788 | y = nullptr; |
| 789 | auto len = MNN::Net::Pack(builderOutput, net.get()); |
| 790 | builderOutput.Finish(len); |
| 791 | } |
| 792 | int sizeOutput = builderOutput.GetSize(); |
| 793 | auto bufferOutput = builderOutput.GetBufferPointer(); |
| 794 | std::shared_ptr<Interpreter> net(Interpreter::createFromBuffer((void*)bufferOutput, sizeOutput), Interpreter::destroy); |
| 795 | ScheduleConfig config; |
| 796 | config.numThread = 1; |
| 797 | int runTime = 5; |
| 798 | auto s0 = net->createSession(config); |
| 799 | { |
| 800 | AUTOTIME; |
| 801 | for (int t = 0; t < runTime; ++t) { |
| 802 | net->runSession(s0); |
| 803 | } |
| 804 | } |
| 805 | net->releaseSession(s0); |
| 806 | config.numThread = 4; |
| 807 | auto s1 = net->createSession(config); |
| 808 | { |
| 809 | AUTOTIME; |
| 810 | for (int t = 0; t < runTime; ++t) { |
| 811 | net->runSession(s1); |
| 812 | } |
| 813 | } |
| 814 | net->releaseSession(s1); |
| 815 | std::vector<std::thread> allThreads; |
| 816 | for (int i = 0; i < 4; ++i) { |
| 817 | allThreads.emplace_back(std::thread([runTime, i, bufferOutput, sizeOutput] { |
| 818 | { |
| 819 | std::shared_ptr<Interpreter> net(Interpreter::createFromBuffer((void*)bufferOutput, sizeOutput), Interpreter::destroy); |
| 820 | ScheduleConfig config; |
| 821 | config.numThread = 4 - i; |
| 822 | BackendConfig bnConfig; |
| 823 | bnConfig.power = MNN::BackendConfig::Power_Normal; |
| 824 | config.backendConfig = &bnConfig; |
| 825 | auto s = net->createSession(config); |
| 826 | AUTOTIME; |
| 827 | for (int t = 0; t < runTime; ++t) { |
| 828 | net->runSession(s); |
| 829 | } |
| 830 | net->releaseSession(s); |
| 831 | } |
| 832 | })); |
| 833 | } |
| 834 | for (auto& t : allThreads) { |
| 835 | t.join(); |
| 836 | } |
| 837 | for (int i=0; i<3; ++i) { |
| 838 | auto rt = Interpreter::createRuntime({config}); |
| 839 | auto s0 = net->createSession(config, rt); |
nothing calls this directly
no test coverage detected