| 18 | class MultiThreadLoadTest : public MNNTestCase { |
| 19 | public: |
| 20 | virtual bool run(int precision) { |
| 21 | auto x1 = _Input({4}, NHWC, halide_type_of<float>()); |
| 22 | auto x0 = _Input({4}, NCHW, halide_type_of<float>()); |
| 23 | auto y = _Add(x1, x0); |
| 24 | y = _Abs(y); |
| 25 | y = _Sign(y); |
| 26 | y = _Square(y); |
| 27 | y = _Cos(y); |
| 28 | y = _Exp(y); |
| 29 | std::unique_ptr<MNN::NetT> net(new NetT); |
| 30 | Variable::save({y}, net.get()); |
| 31 | flatbuffers::FlatBufferBuilder builderOutput(1024); |
| 32 | auto len = MNN::Net::Pack(builderOutput, net.get()); |
| 33 | builderOutput.Finish(len); |
| 34 | int sizeOutput = builderOutput.GetSize(); |
| 35 | auto bufferOutput = builderOutput.GetBufferPointer(); |
| 36 | |
| 37 | auto forwardType = getCurrentType(); |
| 38 | for(int n = 0; n < 100; ++n){ |
| 39 | std::vector<std::thread> threads; |
| 40 | for (int i = 0; i < 4; ++i) { |
| 41 | threads.emplace_back([&]() { |
| 42 | std::shared_ptr<Interpreter> interp(Interpreter::createFromBuffer(bufferOutput, sizeOutput)); |
| 43 | ScheduleConfig config; |
| 44 | config.type = forwardType; |
| 45 | auto session = interp->createSession(config); |
| 46 | interp->runSession(session); |
| 47 | }); |
| 48 | } |
| 49 | for (auto& t : threads) { |
| 50 | t.join(); |
| 51 | } |
| 52 | } |
| 53 | return true; |
| 54 | } |
| 55 | }; |
| 56 | MNNTestSuiteRegister(MultiThreadLoadTest, "expr/MultiThreadLoad"); |
nothing calls this directly
no test coverage detected