| 9 | using namespace MNN::Express; |
| 10 | |
| 11 | static 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 | |
| 46 | static VARP makeInput(float base) { |
| 47 | auto x = _Input({1, 4, 32, 32}, NCHW, halide_type_of<float>()); |
no test coverage detected