• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 // Copyright 2019 Google LLC
2 //
3 // This source code is licensed under the BSD-style license found in the
4 // LICENSE file in the root directory of this source tree.
5 
6 #include <gtest/gtest.h>
7 
8 #include "resize-bilinear-operator-tester.h"
9 
10 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_centers_upscale_y)11 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_centers_upscale_y) {
12   for (size_t input_height = 1; input_height <= 3; input_height++) {
13     for (size_t output_height = input_height + 1; output_height < 15; output_height *= 3) {
14       ResizeBilinearOperatorTester()
15         .input_size(input_height, 1)
16         .output_size(output_height, 1)
17         .channels(17)
18         .iterations(3)
19         .TestNHWCxF32();
20     }
21   }
22 }
23 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_centers_upscale_x)24 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_centers_upscale_x) {
25   for (size_t input_width = 1; input_width <= 3; input_width++) {
26     for (size_t output_width = input_width + 1; output_width < 15; output_width *= 3) {
27       ResizeBilinearOperatorTester()
28         .input_size(1, input_width)
29         .output_size(1, output_width)
30         .channels(17)
31         .iterations(3)
32         .TestNHWCxF32();
33     }
34   }
35 }
36 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_centers_upscale)37 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_centers_upscale) {
38   for (size_t output_height = 3; output_height <= 5; output_height += 2) {
39     for (size_t output_width = 3; output_width <= 5; output_width += 2) {
40       ResizeBilinearOperatorTester()
41         .input_size(2, 2)
42         .output_size(output_height, output_width)
43         .channels(17)
44         .iterations(3)
45         .TestNHWCxF32();
46     }
47   }
48 }
49 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_centers_downscale_y)50 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_centers_downscale_y) {
51   for (size_t output_height = 1; output_height <= 3; output_height++) {
52     for (size_t input_height = output_height + 1; input_height < 15; input_height *= 3) {
53       ResizeBilinearOperatorTester()
54         .input_size(input_height, 1)
55         .output_size(output_height, 1)
56         .channels(17)
57         .iterations(3)
58         .TestNHWCxF32();
59     }
60   }
61 }
62 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_centers_downscale_x)63 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_centers_downscale_x) {
64   for (size_t output_width = 1; output_width <= 3; output_width++) {
65     for (size_t input_width = output_width + 1; input_width < 15; input_width *= 3) {
66       ResizeBilinearOperatorTester()
67         .input_size(1, input_width)
68         .output_size(1, output_width)
69         .channels(17)
70         .iterations(3)
71         .TestNHWCxF32();
72     }
73   }
74 }
75 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_centers_downscale)76 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_centers_downscale) {
77   for (size_t input_height = 3; input_height <= 5; input_height += 2) {
78     for (size_t input_width = 3; input_width <= 5; input_width += 2) {
79       ResizeBilinearOperatorTester()
80         .input_size(input_height, input_width)
81         .output_size(2, 2)
82         .channels(17)
83         .iterations(3)
84         .TestNHWCxF32();
85     }
86   }
87 }
88 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_centers_identical_size)89 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_centers_identical_size) {
90   for (size_t height = 1; height < 10; height *= 3) {
91     for (size_t width = 1; width < 10; width *= 3) {
92       ResizeBilinearOperatorTester()
93         .input_size(height, width)
94         .output_size(height, width)
95         .channels(17)
96         .iterations(3)
97         .TestNHWCxF32();
98     }
99   }
100 }
101 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_centers_varying_channels)102 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_centers_varying_channels) {
103   for (size_t input_size = 2; input_size <= 6; input_size += 2) {
104     for (size_t output_size = 2; output_size <= 6; output_size += 2) {
105       for (size_t channels = 15; channels <= 19; channels++) {
106         ResizeBilinearOperatorTester()
107           .input_size(output_size, output_size)
108           .output_size(output_size, output_size)
109           .channels(channels)
110           .iterations(3)
111           .TestNHWCxF32();
112       }
113     }
114   }
115 }
116 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_centers_with_input_stride)117 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_centers_with_input_stride) {
118   for (size_t input_size = 2; input_size <= 6; input_size += 2) {
119     for (size_t output_size = 2; output_size <= 6; output_size += 2) {
120       for (size_t channels = 15; channels <= 19; channels++) {
121         ResizeBilinearOperatorTester()
122           .input_size(output_size, output_size)
123           .output_size(output_size, output_size)
124           .channels(channels)
125           .input_pixel_stride(23)
126           .iterations(3)
127           .TestNHWCxF32();
128       }
129     }
130   }
131 }
132 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_centers_with_output_stride)133 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_centers_with_output_stride) {
134   for (size_t input_size = 2; input_size <= 6; input_size += 2) {
135     for (size_t output_size = 2; output_size <= 6; output_size += 2) {
136       for (size_t channels = 15; channels <= 19; channels++) {
137         ResizeBilinearOperatorTester()
138           .input_size(output_size, output_size)
139           .output_size(output_size, output_size)
140           .channels(channels)
141           .output_pixel_stride(29)
142           .iterations(3)
143           .TestNHWCxF32();
144       }
145     }
146   }
147 }
148 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_centers_varying_batch_size)149 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_centers_varying_batch_size) {
150   for (size_t input_size = 2; input_size <= 6; input_size += 2) {
151     for (size_t output_size = 2; output_size <= 6; output_size += 2) {
152       for (size_t batch_size = 2; batch_size <= 3; batch_size++) {
153         ResizeBilinearOperatorTester()
154           .batch_size(batch_size)
155           .input_size(output_size, output_size)
156           .output_size(output_size, output_size)
157           .iterations(3)
158           .TestNHWCxF32();
159       }
160     }
161   }
162 }
163 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_corners_upscale_y)164 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_corners_upscale_y) {
165   for (size_t input_height = 1; input_height <= 3; input_height++) {
166     for (size_t output_height = input_height + 1; output_height < 15; output_height *= 3) {
167       ResizeBilinearOperatorTester()
168         .align_corners(true)
169         .input_size(input_height, 1)
170         .output_size(output_height, 1)
171         .channels(17)
172         .iterations(3)
173         .TestNHWCxF32();
174     }
175   }
176 }
177 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_corners_upscale_x)178 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_corners_upscale_x) {
179   for (size_t input_width = 1; input_width <= 3; input_width++) {
180     for (size_t output_width = input_width + 1; output_width < 15; output_width *= 3) {
181       ResizeBilinearOperatorTester()
182         .align_corners(true)
183         .input_size(1, input_width)
184         .output_size(1, output_width)
185         .channels(17)
186         .iterations(3)
187         .TestNHWCxF32();
188     }
189   }
190 }
191 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_corners_upscale)192 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_corners_upscale) {
193   for (size_t output_height = 3; output_height <= 5; output_height += 2) {
194     for (size_t output_width = 3; output_width <= 5; output_width += 2) {
195       ResizeBilinearOperatorTester()
196         .align_corners(true)
197         .input_size(2, 2)
198         .output_size(output_height, output_width)
199         .channels(17)
200         .iterations(3)
201         .TestNHWCxF32();
202     }
203   }
204 }
205 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_corners_downscale_y)206 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_corners_downscale_y) {
207   for (size_t output_height = 2; output_height <= 3; output_height++) {
208     for (size_t input_height = output_height + 1; input_height < 15; input_height *= 3) {
209       ResizeBilinearOperatorTester()
210         .input_size(input_height, 1)
211         .output_size(output_height, 1)
212         .channels(17)
213         .iterations(3)
214         .TestNHWCxF32();
215     }
216   }
217 }
218 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_corners_downscale_x)219 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_corners_downscale_x) {
220   for (size_t output_width = 2; output_width <= 3; output_width++) {
221     for (size_t input_width = output_width + 1; input_width < 15; input_width *= 3) {
222       ResizeBilinearOperatorTester()
223         .input_size(1, input_width)
224         .output_size(1, output_width)
225         .channels(17)
226         .iterations(3)
227         .TestNHWCxF32();
228     }
229   }
230 }
231 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_corners_downscale)232 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_corners_downscale) {
233   for (size_t input_height = 3; input_height <= 5; input_height += 2) {
234     for (size_t input_width = 3; input_width <= 5; input_width += 2) {
235       ResizeBilinearOperatorTester()
236         .input_size(input_height, input_width)
237         .output_size(2, 2)
238         .channels(17)
239         .iterations(3)
240         .TestNHWCxF32();
241     }
242   }
243 }
244 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_corners_identical_size)245 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_corners_identical_size) {
246   for (size_t height = 1; height < 10; height *= 3) {
247     for (size_t width = 1; width < 10; width *= 3) {
248       ResizeBilinearOperatorTester()
249         .align_corners(true)
250         .input_size(height, width)
251         .output_size(height, width)
252         .channels(17)
253         .iterations(3)
254         .TestNHWCxF32();
255     }
256   }
257 }
258 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_corners_varying_channels)259 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_corners_varying_channels) {
260   for (size_t input_size = 2; input_size <= 6; input_size += 2) {
261     for (size_t output_size = 2; output_size <= 6; output_size += 2) {
262       for (size_t channels = 15; channels <= 19; channels++) {
263         ResizeBilinearOperatorTester()
264           .align_corners(true)
265           .input_size(output_size, output_size)
266           .output_size(output_size, output_size)
267           .channels(channels)
268           .iterations(3)
269           .TestNHWCxF32();
270       }
271     }
272   }
273 }
274 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_corners_with_input_stride)275 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_corners_with_input_stride) {
276   for (size_t input_size = 2; input_size <= 6; input_size += 2) {
277     for (size_t output_size = 2; output_size <= 6; output_size += 2) {
278       for (size_t channels = 15; channels <= 19; channels++) {
279         ResizeBilinearOperatorTester()
280           .align_corners(true)
281           .input_size(output_size, output_size)
282           .output_size(output_size, output_size)
283           .channels(channels)
284           .input_pixel_stride(23)
285           .iterations(3)
286           .TestNHWCxF32();
287       }
288     }
289   }
290 }
291 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_corners_with_output_stride)292 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_corners_with_output_stride) {
293   for (size_t input_size = 2; input_size <= 6; input_size += 2) {
294     for (size_t output_size = 2; output_size <= 6; output_size += 2) {
295       for (size_t channels = 15; channels <= 19; channels++) {
296         ResizeBilinearOperatorTester()
297           .align_corners(true)
298           .input_size(output_size, output_size)
299           .output_size(output_size, output_size)
300           .channels(channels)
301           .output_pixel_stride(29)
302           .iterations(3)
303           .TestNHWCxF32();
304       }
305     }
306   }
307 }
308 
TEST(RESIZE_BILINEAR_NHWC_F32,aligned_corners_varying_batch_size)309 TEST(RESIZE_BILINEAR_NHWC_F32, aligned_corners_varying_batch_size) {
310   for (size_t input_size = 2; input_size <= 6; input_size += 2) {
311     for (size_t output_size = 2; output_size <= 6; output_size += 2) {
312       for (size_t batch_size = 2; batch_size <= 3; batch_size++) {
313         ResizeBilinearOperatorTester()
314           .align_corners(true)
315           .batch_size(batch_size)
316           .input_size(output_size, output_size)
317           .output_size(output_size, output_size)
318           .iterations(3)
319           .TestNHWCxF32();
320       }
321     }
322   }
323 }
324 
TEST(RESIZE_BILINEAR_NHWC_F32,tf_mode_aligned_centers_upscale_y)325 TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_centers_upscale_y) {
326   for (size_t input_height = 1; input_height <= 3; input_height++) {
327     for (size_t output_height = input_height + 1; output_height < 15; output_height *= 3) {
328       ResizeBilinearOperatorTester()
329         .tf_legacy_mode(true)
330         .input_size(input_height, 1)
331         .output_size(output_height, 1)
332         .channels(17)
333         .iterations(3)
334         .TestNHWCxF32();
335     }
336   }
337 }
338 
TEST(RESIZE_BILINEAR_NHWC_F32,tf_mode_aligned_centers_upscale_x)339 TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_centers_upscale_x) {
340   for (size_t input_width = 1; input_width <= 3; input_width++) {
341     for (size_t output_width = input_width + 1; output_width < 15; output_width *= 3) {
342       ResizeBilinearOperatorTester()
343         .tf_legacy_mode(true)
344         .input_size(1, input_width)
345         .output_size(1, output_width)
346         .channels(17)
347         .iterations(3)
348         .TestNHWCxF32();
349     }
350   }
351 }
352 
TEST(RESIZE_BILINEAR_NHWC_F32,tf_mode_aligned_centers_upscale)353 TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_centers_upscale) {
354   for (size_t output_height = 3; output_height <= 5; output_height += 2) {
355     for (size_t output_width = 3; output_width <= 5; output_width += 2) {
356       ResizeBilinearOperatorTester()
357         .tf_legacy_mode(true)
358         .input_size(2, 2)
359         .output_size(output_height, output_width)
360         .channels(17)
361         .iterations(3)
362         .TestNHWCxF32();
363     }
364   }
365 }
366 
TEST(RESIZE_BILINEAR_NHWC_F32,tf_mode_aligned_centers_downscale_y)367 TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_centers_downscale_y) {
368   for (size_t output_height = 1; output_height <= 3; output_height++) {
369     for (size_t input_height = output_height + 1; input_height < 15; input_height *= 3) {
370       ResizeBilinearOperatorTester()
371         .tf_legacy_mode(true)
372         .input_size(input_height, 1)
373         .output_size(output_height, 1)
374         .channels(17)
375         .iterations(3)
376         .TestNHWCxF32();
377     }
378   }
379 }
380 
TEST(RESIZE_BILINEAR_NHWC_F32,tf_mode_aligned_centers_downscale_x)381 TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_centers_downscale_x) {
382   for (size_t output_width = 1; output_width <= 3; output_width++) {
383     for (size_t input_width = output_width + 1; input_width < 15; input_width *= 3) {
384       ResizeBilinearOperatorTester()
385         .tf_legacy_mode(true)
386         .input_size(1, input_width)
387         .output_size(1, output_width)
388         .channels(17)
389         .iterations(3)
390         .TestNHWCxF32();
391     }
392   }
393 }
394 
TEST(RESIZE_BILINEAR_NHWC_F32,tf_mode_aligned_centers_downscale)395 TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_centers_downscale) {
396   for (size_t input_height = 3; input_height <= 5; input_height += 2) {
397     for (size_t input_width = 3; input_width <= 5; input_width += 2) {
398       ResizeBilinearOperatorTester()
399         .tf_legacy_mode(true)
400         .input_size(input_height, input_width)
401         .output_size(2, 2)
402         .channels(17)
403         .iterations(3)
404         .TestNHWCxF32();
405     }
406   }
407 }
408 
TEST(RESIZE_BILINEAR_NHWC_F32,tf_mode_aligned_centers_identical_size)409 TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_centers_identical_size) {
410   for (size_t height = 1; height < 10; height *= 3) {
411     for (size_t width = 1; width < 10; width *= 3) {
412       ResizeBilinearOperatorTester()
413         .tf_legacy_mode(true)
414         .input_size(height, width)
415         .output_size(height, width)
416         .channels(17)
417         .iterations(3)
418         .TestNHWCxF32();
419     }
420   }
421 }
422 
TEST(RESIZE_BILINEAR_NHWC_F32,tf_mode_aligned_centers_varying_channels)423 TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_centers_varying_channels) {
424   for (size_t input_size = 2; input_size <= 6; input_size += 2) {
425     for (size_t output_size = 2; output_size <= 6; output_size += 2) {
426       for (size_t channels = 15; channels <= 19; channels++) {
427         ResizeBilinearOperatorTester()
428           .tf_legacy_mode(true)
429           .input_size(output_size, output_size)
430           .output_size(output_size, output_size)
431           .channels(channels)
432           .iterations(3)
433           .TestNHWCxF32();
434       }
435     }
436   }
437 }
438 
TEST(RESIZE_BILINEAR_NHWC_F32,tf_mode_aligned_centers_with_input_stride)439 TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_centers_with_input_stride) {
440   for (size_t input_size = 2; input_size <= 6; input_size += 2) {
441     for (size_t output_size = 2; output_size <= 6; output_size += 2) {
442       for (size_t channels = 15; channels <= 19; channels++) {
443         ResizeBilinearOperatorTester()
444           .tf_legacy_mode(true)
445           .input_size(output_size, output_size)
446           .output_size(output_size, output_size)
447           .channels(channels)
448           .input_pixel_stride(23)
449           .iterations(3)
450           .TestNHWCxF32();
451       }
452     }
453   }
454 }
455 
TEST(RESIZE_BILINEAR_NHWC_F32,tf_mode_aligned_centers_with_output_stride)456 TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_centers_with_output_stride) {
457   for (size_t input_size = 2; input_size <= 6; input_size += 2) {
458     for (size_t output_size = 2; output_size <= 6; output_size += 2) {
459       for (size_t channels = 15; channels <= 19; channels++) {
460         ResizeBilinearOperatorTester()
461           .tf_legacy_mode(true)
462           .input_size(output_size, output_size)
463           .output_size(output_size, output_size)
464           .channels(channels)
465           .output_pixel_stride(29)
466           .iterations(3)
467           .TestNHWCxF32();
468       }
469     }
470   }
471 }
472 
TEST(RESIZE_BILINEAR_NHWC_F32,tf_mode_aligned_centers_varying_batch_size)473 TEST(RESIZE_BILINEAR_NHWC_F32, tf_mode_aligned_centers_varying_batch_size) {
474   for (size_t input_size = 2; input_size <= 6; input_size += 2) {
475     for (size_t output_size = 2; output_size <= 6; output_size += 2) {
476       for (size_t batch_size = 2; batch_size <= 3; batch_size++) {
477         ResizeBilinearOperatorTester()
478           .tf_legacy_mode(true)
479           .batch_size(batch_size)
480           .input_size(output_size, output_size)
481           .output_size(output_size, output_size)
482           .iterations(3)
483           .TestNHWCxF32();
484       }
485     }
486   }
487 }
488