| 24 | |
| 25 | protected: |
| 26 | bool testOnBackend(MNNForwardType type, const std::string& deviceName, int precision) { |
| 27 | // MultiInput Deconv |
| 28 | { |
| 29 | const int inputHeight = 3, inputWidth = 3, inputChannel = 3, outputChannel = 2; |
| 30 | const int kernelSize = 3, stride = 2, pad = 1, batch = 2; |
| 31 | const int height = (inputHeight - 1) * stride + kernelSize - pad * 2; // height = 5 |
| 32 | const int width = (inputWidth - 1) * stride + kernelSize - pad * 2; // width = 5 |
| 33 | const std::vector<float> inputData = { |
| 34 | // channel 0 |
| 35 | 0.0500, 0.2283, 0.9916, 0.5502, 0.2731, 0.0964, 0.5169, 0.3492, 0.0057, |
| 36 | // channel 1 |
| 37 | 0.5207, 0.2388, 0.2215, 0.7307, 0.4999, 0.7638, 0.3025, 0.7966, 0.7117, |
| 38 | // channel 2 |
| 39 | 0.3264, 0.1317, 0.9161, 0.8626, 0.9634, 0.1032, 0.4114, 0.7719, 0.1408, |
| 40 | // channel 0 |
| 41 | 0.0500, 0.2283, 0.9916, 0.5502, 0.2731, 0.0964, 0.5169, 0.3492, 0.0057, |
| 42 | // channel 1 |
| 43 | 0.5207, 0.2388, 0.2215, 0.7307, 0.4999, 0.7638, 0.3025, 0.7966, 0.7117, |
| 44 | // channel 2 |
| 45 | 0.3264, 0.1317, 0.9161, 0.8626, 0.9634, 0.1032, 0.4114, 0.7719, 0.1408 |
| 46 | }; |
| 47 | const std::vector<float> filterData = { |
| 48 | // outputChannel = 0, inputChannel = 0 |
| 49 | 0.7648, 0.83, 0.3509, 0.8953, 0.7895, 0.4066, 0.5893, 0.9506, 0.4081, |
| 50 | // outputChannel = 1, inputChannel = 0 |
| 51 | 0.1982, 0.2179, 0.2756, 0.5602, 0.2062, 0.8441, 0.6934, 0.5666, 0.765, |
| 52 | // outputChannel = 0, inputChannel = 1 |
| 53 | 0.0375, 0.2276, 0.6908, 0.2677, 0.2822, 0.9121, 0.0821, 0.1406, 0.1126, |
| 54 | // outputChannel = 1, inputChannel = 1 |
| 55 | 0.3432, 0.4277, 0.6015, 0.0909, 0.957, 0.3732, 0.4586, 0.2034, 0.5555, |
| 56 | // outputChannel = 0, inputChannel = 2 |
| 57 | 0.8036, 0.8453, 0.226, 0.6534, 0.7527, 0.9455, 0.0295, 0.1798, 0.4561, |
| 58 | // outputChannel = 1, inputChannel = 2 |
| 59 | 0.3859, 0.1691, 0.7373, 0.246, 0.7928, 0.4552, 0.8937, 0.4109, 0.3926}; |
| 60 | const std::vector<float> biasData = {1.0, 0.0}; |
| 61 | const std::vector<float> outputData = { |
| 62 | // channel 0 |
| 63 | 1.432098, 2.158248, 1.346763, 2.980813, 2.534924, 2.531556, 3.280517, 2.429089, 2.653877, 2.479560, |
| 64 | 2.289865, 3.713586, 2.081835, 2.836103, 1.369331, 2.626485, 3.331208, 2.626743, 2.721178, 1.503316, |
| 65 | 1.803119, 2.905308, 2.081503, 2.886019, 1.311322, |
| 66 | // channel 1 |
| 67 | 0.767390, 0.567106, 0.380019, 1.142767, 1.142727, 0.846633, 2.665777, 0.668269, 3.374221, 1.348453, |
| 68 | 1.496601, 1.565205, 1.298501, 1.004446, 0.832651, 1.126390, 3.713293, 1.199604, 2.818435, 0.581827, |
| 69 | 0.722235, 1.194398, 1.446314, 1.045943, 0.793899, |
| 70 | // channel 0 |
| 71 | 1.432098, 2.158248, 1.346763, 2.980813, 2.534924, 2.531556, 3.280517, 2.429089, 2.653877, 2.479560, |
| 72 | 2.289865, 3.713586, 2.081835, 2.836103, 1.369331, 2.626485, 3.331208, 2.626743, 2.721178, 1.503316, |
| 73 | 1.803119, 2.905308, 2.081503, 2.886019, 1.311322, |
| 74 | // channel 1 |
| 75 | 0.767390, 0.567106, 0.380019, 1.142767, 1.142727, 0.846633, 2.665777, 0.668269, 3.374221, 1.348453, |
| 76 | 1.496601, 1.565205, 1.298501, 1.004446, 0.832651, 1.126390, 3.713293, 1.199604, 2.818435, 0.581827, |
| 77 | 0.722235, 1.194398, 1.446314, 1.045943, 0.793899 |
| 78 | }; |
| 79 | |
| 80 | auto input = _Input({batch, inputChannel, inputHeight, inputWidth}, NCHW, halide_type_of<float>()); |
| 81 | auto filter = _Input({inputChannel, outputChannel, kernelSize, kernelSize}, NCHW, halide_type_of<float>()); |
| 82 | auto bias = _Input({outputChannel}, NCHW, halide_type_of<float>()); |
| 83 | auto output = |