| 879 | class MultiThreadOneSessionTest : public MNNTestCase { |
| 880 | public: |
| 881 | bool _run(int precision, bool lazy) { |
| 882 | flatbuffers::FlatBufferBuilder builderOutput(1024); |
| 883 | { |
| 884 | auto y = _mobileNetV1Expr(); |
| 885 | std::unique_ptr<MNN::NetT> net(new NetT); |
| 886 | Variable::save({y}, net.get()); |
| 887 | y = nullptr; |
| 888 | auto len = MNN::Net::Pack(builderOutput, net.get()); |
| 889 | builderOutput.Finish(len); |
| 890 | } |
| 891 | int sizeOutput = builderOutput.GetSize(); |
| 892 | auto bufferOutput = builderOutput.GetBufferPointer(); |
| 893 | std::shared_ptr<Interpreter> net(Interpreter::createFromBuffer((void*)bufferOutput, sizeOutput), Interpreter::destroy); |
| 894 | ScheduleConfig config; |
| 895 | config.numThread = 4; |
| 896 | auto s1 = net->createSession(config); |
| 897 | std::vector<std::thread> allThreads; |
| 898 | for (int i = 0; i < 4; ++i) { |
| 899 | allThreads.emplace_back(std::thread([net, s1] { |
| 900 | net->runSession(s1); |
| 901 | })); |
| 902 | } |
| 903 | for (auto& t : allThreads) { |
| 904 | t.join(); |
| 905 | } |
| 906 | return true; |
| 907 | } |
| 908 | virtual bool run(int precision) { |
| 909 | auto res = _run(precision, true); |
| 910 | return res; |
nothing calls this directly
no test coverage detected