def test_gradcheck(self): input = torch.tensor([[0., 0., 0.], [0., 0., 0.], [0., 1., 1.]]).double() # 3 x 3 input = utils.tensor_to_gradcheck_var(input) # to var assert gradcheck(kornia.Rot180(), (input, ), raise_exception=True)
def test_gradcheck(self, device, dtype): input = torch.tensor([[0., 0., 0.], [0., 0., 0.], [0., 1., 1.]], device=device, dtype=dtype) # 3 x 3 input = utils.tensor_to_gradcheck_var(input) # to var assert gradcheck(kornia.Rot180(), (input, ), raise_exception=True)
def test_rot180(self): f = kornia.Rot180() input = torch.tensor([[0., 0., 0.], [0., 0., 0.], [0., 1., 1.]]) # 3 x 3 expected = torch.tensor([[1., 1., 0.], [0., 0., 0.], [0., 0., 0.]]) # 3 x 3 assert (f(input) == expected).all()
def test_rot180(self, device, dtype): f = kornia.Rot180() input = torch.tensor([[0., 0., 0.], [0., 0., 0.], [0., 1., 1.]], device=device, dtype=dtype) # 3 x 3 expected = torch.tensor([[1., 1., 0.], [0., 0., 0.], [0., 0., 0.]], device=device, dtype=dtype) # 3 x 3 assert (f(input) == expected).all()
def test_batch_rot180(self): input = torch.tensor([[0., 0., 0.], [0., 0., 0.], [0., 1., 1.]]) # 3 x 3 input = input.repeat(2, 1, 1) # 2 x 3 x 3 f = kornia.Rot180() expected = torch.tensor([[1., 1., 0.], [0., 0., 0.], [0., 0., 0.]]) # 1 x 3 x 3 expected = expected.repeat(2, 1, 1) # 2 x 3 x 3 assert (f(input) == expected).all()
def test_batch_rot180(self, device, dtype): input = torch.tensor( [[0.0, 0.0, 0.0], [0.0, 0.0, 0.0], [0.0, 1.0, 1.0]], device=device, dtype=dtype) # 3 x 3 input = input.repeat(2, 1, 1) # 2 x 3 x 3 f = kornia.Rot180() expected = torch.tensor( [[1.0, 1.0, 0.0], [0.0, 0.0, 0.0], [0.0, 0.0, 0.0]], device=device, dtype=dtype) # 1 x 3 x 3 expected = expected.repeat(2, 1, 1) # 2 x 3 x 3 assert (f(input) == expected).all()
def smoke_test(self, device, dtype): f = kornia.Rot180() repr = "Rot180()" assert str(f) == repr
def op_script(data: torch.Tensor) -> torch.Tensor: return kornia.Rot180(data)
def smoke_test(self): f = kornia.Rot180() repr = "Rot180()" assert str(f) == repr