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

Function residual

benchmark/exprModels/ResNetExpr.cpp:19–28  ·  view source on GitHub ↗

When we use MNNConverter to convert other resnet model to MNN model, {Conv + BN + Relu} will be converted and optimized to {Conv}

Source from the content-addressed store, hash-verified

17// When we use MNNConverter to convert other resnet model to MNN model,
18// {Conv + BN + Relu} will be converted and optimized to {Conv}
19static VARP residual(VARP x, INTS channels, int stride) {
20 int inputChannel = x->getInfo()->dim[1], outputChannel = channels[1];
21 auto y = _Conv(0.0f, 0.0f, x, {inputChannel, outputChannel}, {3, 3}, SAME, {stride, stride}, {1, 1}, 1);
22 y = _Conv(0.0f, 0.0f, y, {outputChannel, outputChannel}, {3, 3}, SAME, {1, 1}, {1, 1}, 1);
23 if (inputChannel != outputChannel || stride != 1) {
24 x = _Conv(0.0f, 0.0f, x, {inputChannel, outputChannel}, {1, 1}, SAME, {stride, stride}, {1, 1}, 1);
25 }
26 y = _Add(x, y);
27 return y;
28}
29
30static VARP residualBlock(VARP x, INTS channels, int stride, int number) {
31 x = residual(x, {channels[0], channels[1]}, stride);

Callers 1

residualBlockFunction · 0.85

Calls 3

_AddFunction · 0.85
_ConvFunction · 0.50
getInfoMethod · 0.45

Tested by

no test coverage detected