def test_hflip(self): img_tensor = torch.randn(3, 16, 16) img_tensor_clone = img_tensor.clone() hflipped_img = F_t.hflip(img_tensor) hflipped_img_again = F_t.hflip(hflipped_img) self.assertEqual(hflipped_img.shape, img_tensor.shape) self.assertTrue(torch.equal(img_tensor, hflipped_img_again)) self.assertTrue(torch.equal(img_tensor, img_tensor_clone))
def test_hflip(self): script_hflip = torch.jit.script(F_t.hflip) img_tensor = torch.randn(3, 16, 16) img_tensor_clone = img_tensor.clone() hflipped_img = F_t.hflip(img_tensor) hflipped_img_again = F_t.hflip(hflipped_img) self.assertEqual(hflipped_img.shape, img_tensor.shape) self.assertTrue(torch.equal(img_tensor, hflipped_img_again)) self.assertTrue(torch.equal(img_tensor, img_tensor_clone)) # scriptable function test hflipped_img_script = script_hflip(img_tensor) self.assertTrue(torch.equal(hflipped_img, hflipped_img_script))