| 44 | } |
| 45 | |
| 46 | VARP shuffleNetExpr(int group, int numClass) { |
| 47 | std::map<int, std::vector<int>> groupMap = { |
| 48 | {1, {144, 288, 576}}, |
| 49 | {2, {200, 400, 800}}, |
| 50 | {3, {240, 480, 960}}, |
| 51 | {4, {272, 544, 1088}}, |
| 52 | {8, {384, 768, 1536}} |
| 53 | }; |
| 54 | int outputChannelStage2 = groupMap[group][0]; |
| 55 | int outputChannelStage3 = groupMap[group][1]; |
| 56 | int outputChannelStage4 = groupMap[group][2]; |
| 57 | // Net Construction |
| 58 | auto x = _Input({1, 3, 224, 224}, NC4HW4); |
| 59 | x = _Conv(0.0f, 0.0f, x, {3, 24}, {3, 3}, SAME, {2, 2}, {1, 1}, 1); |
| 60 | x = _MaxPool(x, {3, 3}, {2, 2}, SAME); |
| 61 | x = shuffleBlock(x, 24, outputChannelStage2, group, 2, 4, 4); |
| 62 | x = shuffleBlock(x, outputChannelStage2, outputChannelStage3, group, 2, 4, 8); |
| 63 | x = shuffleBlock(x, outputChannelStage3, outputChannelStage4, group, 2, 4, 4); |
| 64 | x = _AvePool(x, {7, 7}, {1, 1}, VALID); |
| 65 | x = _Conv(0.0f, 0.0f, x, {outputChannelStage4, numClass}, {1, 1}, VALID, {1, 1}, {1, 1}, 1); // replace FC with Conv1x1 |
| 66 | return x; |
| 67 | } |