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

Method run

test/expr/ZeroShapeTest.cpp:66–116  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

64class ZeroShapeTest3 : public MNNTestCase {
65public:
66 virtual bool run(int precision) {
67 auto input = _Input({1, 0, 4, 1}, NHWC);
68 input->setName("input");
69 std::unique_ptr<MNN::OpT> op(new MNN::OpT);
70 op->type = MNN::OpType_Unpack;
71 op->main.value = new MNN::AxisT;
72 op->main.type = MNN::OpParameter_Axis;
73 op->main.AsAxis()->axis = 1;
74 auto expr = Expr::create(op.get(), {input}, 3);
75 auto output = Variable::create(expr, 0);
76 auto info = output->getInfo();
77 if (nullptr != info) {
78 FUNC_PRINT(1);
79 return false;
80 }
81 auto sliceOutput = _Split(input, {4}, 2);
82 std::vector<int> dstDims = {1, 0, 1, 1};
83 for (auto s : sliceOutput) {
84 auto info = s->getInfo();
85 if (info->dim != dstDims) {
86 FUNC_PRINT(1);
87 return false;
88 }
89 auto ptr = s->readMap<float>();
90 if (nullptr != ptr) {
91 FUNC_PRINT(1);
92 return false;
93 }
94 }
95 std::vector<int> padds = {0, 0, 1, 0, 0, 0, 0, 0};
96 auto paddings = _Const(padds.data(), {2, 4}, NHWC, halide_type_of<int>());
97 auto padOutput = _Pad(input, paddings);
98 auto padinfo = padOutput->getInfo();
99 if (padinfo->dim != std::vector<int>{1, 1, 4, 1}) {
100 FUNC_PRINT(1);
101 return false;
102 }
103 input->writeMap<float>();
104 auto ptr = padOutput->readMap<float>();
105 if (nullptr == ptr) {
106 FUNC_PRINT(1);
107 return false;
108 }
109 for (int i = 0; i < padinfo->size; ++i) {
110 if (ptr[i] > 0.000001f) {
111 FUNC_PRINT(1);
112 return false;
113 }
114 }
115 return true;
116 }
117};
118class ZeroShapeTest4 : public MNNTestCase {
119public:

Callers

nothing calls this directly

Calls 10

_InputFunction · 0.85
_SplitFunction · 0.85
_ConstFunction · 0.85
_PadFunction · 0.85
AsAxisMethod · 0.80
createFunction · 0.50
setNameMethod · 0.45
getMethod · 0.45
getInfoMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected