Skip to content

Commit

Permalink
onnx export device mismatch fix (kornia#2999)
Browse files Browse the repository at this point in the history
* onnx export device mismatch fix

* typo fix
  • Loading branch information
Isalia20 authored Aug 30, 2024
1 parent 343357d commit a12d218
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions kornia/geometry/linalg.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,9 @@ def transform_points(trans_01: Tensor, points_1: Tensor) -> Tensor:
shape_inp = list(points_1.shape)
points_1 = points_1.reshape(-1, points_1.shape[-2], points_1.shape[-1])
trans_01 = trans_01.reshape(-1, trans_01.shape[-2], trans_01.shape[-1])
# We expand trans_01 to match the dimensions needed for bmm
trans_01 = torch.repeat_interleave(trans_01, repeats=points_1.shape[0] // trans_01.shape[0], dim=0)
# We expand trans_01 to match the dimensions needed for bmm. repeats input division is cast
# to integer so onnx doesn't record the value as a tensor and get a device mismatch
trans_01 = torch.repeat_interleave(trans_01, repeats=int(points_1.shape[0] // trans_01.shape[0]), dim=0)
# to homogeneous
points_1_h = convert_points_to_homogeneous(points_1) # BxNxD+1
# transform coordinates
Expand Down

0 comments on commit a12d218

Please sign in to comment.