MCPcopy Create free account
hub / github.com/Kaggle/docker-python / test_float_to_float

Method test_float_to_float

tests/test_torchvision.py:9–25  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

7
8class TestTorchvision(unittest.TestCase):
9 def test_float_to_float(self):
10 input_dtype=torch.float32
11 output_dtype=torch.float64
12 input_image = torch.tensor((0.0, 1.0), dtype=input_dtype)
13 transform = transforms.ConvertImageDtype(output_dtype)
14 transform_script = torch.jit.script(F.convert_image_dtype)
15
16 output_image = transform(input_image)
17 output_image_script = transform_script(input_image, output_dtype)
18
19 # TODO(b/181966788) Uncomment after upgrade to pytorch 1.9.0 is done.
20 # torch.testing.assert_close(output_image_script, output_image, rtol=0.0, atol=1e-6)
21
22 actual_min, actual_max = output_image.tolist()
23
24 self.assertAlmostEqual(0, actual_min)
25 self.assertAlmostEqual(1, actual_max)

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected