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

Function makeComplexGraph

test/expr/StaticModuleOutputReuseTest.cpp:11–44  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

9using namespace MNN::Express;
10
11static VARPS makeComplexGraph(VARP x) {
12 // Input: NCHW float, shape {1, 4, 32, 32}
13 // Graph intent:
14 // - Introduce multiple ops (convert/conv/pool/concat/transpose) to increase
15 // intermediate allocations.
16 // - Keep an early large tensor as an output (Aux) to make later output tensor
17 // more likely to be allocated with non-zero offset on Metal.
18
19 auto x4 = _Convert(x, NC4HW4);
20
21 auto c0 = _Conv(0.01f, 0.0f, x4, {4, 8}, {3, 3}, SAME, {1, 1}, {1, 1}, 1);
22 c0 = _Relu(c0);
23
24 auto maxP = _MaxPool(c0, {2, 2}, {2, 2}, VALID);
25 auto aveP = _AvePool(c0, {2, 2}, {2, 2}, VALID);
26
27 auto aux = _Concat({maxP, aveP}, 1);
28 aux->setName("Aux");
29
30 auto c1 = _Conv(0.02f, 0.01f, aux, {16, 4}, {1, 1}, SAME, {1, 1}, {1, 1}, 1);
31 c1 = _Relu6(c1);
32
33 auto y = _Convert(c1, NCHW);
34 y = _Transpose(y, {0, 2, 3, 1});
35 y = _Transpose(y, {0, 3, 1, 2});
36 y = y + _Scalar<float>(1.0f);
37 y = _ReduceSum(y, {2}, true);
38 y->setName("Output");
39
40 auto s = _Shape(y);
41 s->setName("Shape");
42
43 return {aux, y, s};
44}
45
46static VARP makeInput(float base) {
47 auto x = _Input({1, 4, 32, 32}, NCHW, halide_type_of<float>());

Callers 1

runMethod · 0.85

Calls 11

_ConvertFunction · 0.85
_ReluFunction · 0.85
_MaxPoolFunction · 0.85
_AvePoolFunction · 0.85
_ConcatFunction · 0.85
_Relu6Function · 0.85
_TransposeFunction · 0.85
_ReduceSumFunction · 0.85
_ShapeFunction · 0.85
_ConvFunction · 0.50
setNameMethod · 0.45

Tested by

no test coverage detected