| 67 | } |
| 68 | |
| 69 | void Conv2DWithBiasesInt8Test() |
| 70 | { |
| 71 | // Set input data |
| 72 | std::vector<int32_t> inputShape { 1, 2, 2, 1 }; |
| 73 | std::vector<int32_t> filterShape { 1, 2, 2, 1 }; |
| 74 | std::vector<int32_t> biasShape { 1 }; |
| 75 | std::vector<int32_t> outputShape { 1, 2, 2, 1 }; |
| 76 | |
| 77 | static std::vector<int8_t> inputValues = { 1, 2, 3, 4 }; |
| 78 | |
| 79 | std::vector<int8_t> filterValues = { 2, 1, 0, 6 }; |
| 80 | |
| 81 | std::vector<int32_t> biasValues = { 10 }; |
| 82 | |
| 83 | std::vector<int8_t> expectedOutputValues = |
| 84 | { |
| 85 | (1 * 2 + 2 * 1 + 3 * 0 + 4 * 6 + 10) / 2, // 19 |
| 86 | (2 * 2 + 0 * 1 + 4 * 0 + 0 * 6 + 10) / 2, // 7 |
| 87 | (3 * 2 + 4 * 1 + 0 * 0 + 0 * 6 + 10) / 2, // 10 |
| 88 | (4 * 2 + 0 * 1 + 0 * 0 + 0 * 6 + 10) / 2, // 9 |
| 89 | }; |
| 90 | |
| 91 | tflite::Padding padding = tflite::Padding_SAME; |
| 92 | |
| 93 | ConvolutionTest<int8_t, int32_t>(tflite::BuiltinOperator_CONV_2D, |
| 94 | ::tflite::TensorType_INT8, |
| 95 | 1, // strideX |
| 96 | 1, // strideY |
| 97 | 1, // dilationX |
| 98 | 1, // dilationY |
| 99 | padding, |
| 100 | tflite::ActivationFunctionType_NONE, |
| 101 | inputShape, |
| 102 | filterShape, |
| 103 | outputShape, |
| 104 | inputValues, |
| 105 | filterValues, |
| 106 | expectedOutputValues, |
| 107 | biasShape, |
| 108 | biasValues); |
| 109 | } |
| 110 | |
| 111 | void Conv2DWithBiasesReluUint8Test() |
| 112 | { |