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

Method run

test/op/StackTest.cpp:18–39  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

16public:
17 virtual ~StackTest() = default;
18 virtual bool run(int precision) {
19 auto input0 = _Input({3, 1, 2}, NCHW);
20 input0->setName("input0");
21 const float input0_data[] = {1.0, 2.0, 5.0, 6.0, 9.0, 10.0};
22 auto input0Ptr = input0->writeMap<float>();
23 memcpy(input0Ptr, input0_data, 6 * sizeof(float));
24 input0->unMap();
25 auto input1 = _Input({3, 1, 2}, NCHW);
26 input1->setName("input1");
27 const float input1_data[] = {3.0, 4.0, 7.0, 8.0, 11.0, 12.0};
28 auto input1Ptr = input1->writeMap<float>();
29 memcpy(input1Ptr, input1_data, 6 * sizeof(float));
30 input1->unMap();
31 auto output = _Stack({input0, input1}, 2);
32 const std::vector<float> expectedOutput = {1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0};
33 auto gotOutput = output->readMap<float>();
34 if (!checkVector<float>(gotOutput, expectedOutput.data(), 12, 0.01)) {
35 MNN_ERROR("StackTest test failed!\n");
36 return false;
37 }
38 return true;
39 }
40};
41
42MNNTestSuiteRegister(StackTest, "op/stack");

Callers

nothing calls this directly

Calls 5

_InputFunction · 0.85
_StackFunction · 0.85
unMapMethod · 0.80
setNameMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected