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

Method run

test/expr/MultiThreadLoad.cpp:20–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

18class MultiThreadLoadTest : public MNNTestCase {
19public:
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};
56MNNTestSuiteRegister(MultiThreadLoadTest, "expr/MultiThreadLoad");

Callers

nothing calls this directly

Calls 15

_InputFunction · 0.85
_AddFunction · 0.85
_AbsFunction · 0.85
_SignFunction · 0.85
_CosFunction · 0.85
getCurrentTypeFunction · 0.85
runSessionMethod · 0.80
joinMethod · 0.80
_SquareFunction · 0.50
_ExpFunction · 0.50
saveFunction · 0.50
getMethod · 0.45

Tested by

no test coverage detected