| 239 | } |
| 240 | |
| 241 | void StrideTest(TfLiteRegistration* registration, int num_thread) { |
| 242 | DepthwiseConvolutionOpModel m( |
| 243 | registration, {TensorType_FLOAT32, {1, 3, 2, 2}}, |
| 244 | {TensorType_FLOAT32, {1, 2, 2, 4}}, {TensorType_FLOAT32, {}}, |
| 245 | Padding_VALID, |
| 246 | /*dilation_factor*/ 1, |
| 247 | /*stride_width*/ 2, |
| 248 | /*stride_height*/ 2, |
| 249 | /*ActivationFunctionType*/ ActivationFunctionType_NONE); |
| 250 | |
| 251 | m.SetInput({ |
| 252 | 1, 2, 7, 8, // column 1 |
| 253 | 3, 4, 9, 10, // column 2 |
| 254 | 5, 6, 11, 12, // column 3 |
| 255 | }); |
| 256 | m.SetFilter({ |
| 257 | 1, 2, 3, 4, // |
| 258 | -9, 10, -11, 12, // |
| 259 | 5, 6, 7, 8, // |
| 260 | 13, -14, 15, -16, // |
| 261 | }); |
| 262 | m.SetBias({1, 2, 3, 4}); |
| 263 | |
| 264 | m.Invoke(); |
| 265 | |
| 266 | EXPECT_THAT(m.GetOutput(), ElementsAreArray({ |
| 267 | 71, -34, 99, -20, // |
| 268 | })); |
| 269 | } |
| 270 | |
| 271 | TEST_P(DepthwiseConvolutionOpTest, StrideTest) { |
| 272 | StrideTest(GetRegistration(), /*num_thread=*/1); |