(self)
| 2337 | @test_util.disable_xla("align_corners=False not supported by XLA") |
| 2338 | @test_util.run_deprecated_v1 |
| 2339 | def testNoOp(self): |
| 2340 | img_shape = [1, 6, 4, 1] |
| 2341 | single_shape = [6, 4, 1] |
| 2342 | # This test is also conducted with int8, so 127 is the maximum |
| 2343 | # value that can be used. |
| 2344 | data = [ |
| 2345 | 127, 127, 64, 64, 127, 127, 64, 64, 64, 64, 127, 127, 64, 64, 127, 127, |
| 2346 | 50, 50, 100, 100, 50, 50, 100, 100 |
| 2347 | ] |
| 2348 | target_height = 6 |
| 2349 | target_width = 4 |
| 2350 | |
| 2351 | for nptype in self.TYPES: |
| 2352 | img_np = np.array(data, dtype=nptype).reshape(img_shape) |
| 2353 | |
| 2354 | for method in self.METHODS: |
| 2355 | with self.cached_session(use_gpu=True): |
| 2356 | image = constant_op.constant(img_np, shape=img_shape) |
| 2357 | y = image_ops.resize_images_v2(image, [target_height, target_width], |
| 2358 | method) |
| 2359 | yshape = array_ops.shape(y) |
| 2360 | resized, newshape = self.evaluate([y, yshape]) |
| 2361 | self.assertAllEqual(img_shape, newshape) |
| 2362 | if method in self.INTERPOLATING_METHODS: |
| 2363 | self.assertAllClose(resized, img_np, atol=1e-5) |
| 2364 | |
| 2365 | # Resizing with a single image must leave the shape unchanged also. |
| 2366 | with self.cached_session(use_gpu=True): |
| 2367 | img_single = img_np.reshape(single_shape) |
| 2368 | image = constant_op.constant(img_single, shape=single_shape) |
| 2369 | y = image_ops.resize_images_v2(image, [target_height, target_width], |
| 2370 | self.METHODS[0]) |
| 2371 | yshape = array_ops.shape(y) |
| 2372 | newshape = self.evaluate(yshape) |
| 2373 | self.assertAllEqual(single_shape, newshape) |
| 2374 | |
| 2375 | # half_pixel_centers unsupported in ResizeBilinear |
| 2376 | @test_util.run_deprecated_v1 |
nothing calls this directly
no test coverage detected