From e0b2c3efd037599ecde646ea04024c3a5713a0f1 Mon Sep 17 00:00:00 2001 From: isalia20 Date: Wed, 28 Aug 2024 00:26:53 +0400 Subject: [PATCH 1/2] onnx export device mismatch fix --- kornia/geometry/linalg.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/kornia/geometry/linalg.py b/kornia/geometry/linalg.py index bcb77492f4..d2fb20f264 100644 --- a/kornia/geometry/linalg.py +++ b/kornia/geometry/linalg.py @@ -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 divison 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 From cc0d77c231ea32a0433e6f99e6114827d32494f9 Mon Sep 17 00:00:00 2001 From: isalia20 Date: Wed, 28 Aug 2024 00:28:01 +0400 Subject: [PATCH 2/2] typo fix --- kornia/geometry/linalg.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kornia/geometry/linalg.py b/kornia/geometry/linalg.py index d2fb20f264..a786c1d6f0 100644 --- a/kornia/geometry/linalg.py +++ b/kornia/geometry/linalg.py @@ -184,7 +184,7 @@ 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. repeats input divison is cast + # 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