Skip to content

🐍 Geometric Computer Vision Library for Spatial AI

refactor(geometry): remove redundant empty tensor initializations in conversions (#3871)

Shin hyeon binf4564fb9b851
diff --git a/kornia/geometry/conversions.py b/kornia/geometry/conversions.py
index b636a57bb..7a73ec77a 100644
--- a/kornia/geometry/conversions.py
+++ b/kornia/geometry/conversions.py
@@ -637,11 +637,6 @@ def quaternion_to_axis_angle(quaternion: torch.Tensor) -> torch.Tensor:
raise ValueError(f"Input must be a tensor of shape Nx4 or 4. Got {quaternion.shape}")
# unpack input and compute conversion
- q1: torch.Tensor = torch.tensor([])
- q2: torch.Tensor = torch.tensor([])
- q3: torch.Tensor = torch.tensor([])
- cos_theta: torch.Tensor = torch.tensor([])
-
cos_theta = quaternion[..., 0]
q1 = quaternion[..., 1]
q2 = quaternion[..., 2]
@@ -703,7 +698,6 @@ def quaternion_log_to_exp(quaternion: torch.Tensor, eps: float = 1.0e-8) -> torc
quaternion_scalar: torch.Tensor = torch.cos(norm_q)
# compose quaternion and return
- quaternion_exp: torch.Tensor = torch.tensor([])
quaternion_exp = torch.cat((quaternion_scalar, quaternion_vector), dim=-1)
return quaternion_exp
@@ -735,9 +729,6 @@ def quaternion_exp_to_log(quaternion: torch.Tensor, eps: float = 1.0e-8) -> torc
raise ValueError(f"Input must be a tensor of shape (*, 4). Got {quaternion.shape}")
# unpack quaternion vector and scalar
- quaternion_vector: torch.Tensor = torch.tensor([])
- quaternion_scalar: torch.Tensor = torch.tensor([])
-
quaternion_scalar = quaternion[..., 0:1]
quaternion_vector = quaternion[..., 1:4]