From d6a12afbe77f8129b9285b30343b33e9cbf1bdec Mon Sep 17 00:00:00 2001 From: Jeremy Reizenstein Date: Thu, 6 Jan 2022 02:21:48 -0800 Subject: [PATCH] Pointclouds.subsample on Windows Summary: Fix https://github.com/facebookresearch/pytorch3d/issues/1015. Stop relying on the fact that the dtype returned by np.random.choice (int64 on Linux, int32 on Windows) matches the dtype used by pytorch for indexing (int64 everywhere). Reviewed By: patricklabatut Differential Revision: D33428680 fbshipit-source-id: 716c857502cd54c563cb256f0eaca7dccd535c10 --- pytorch3d/structures/pointclouds.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pytorch3d/structures/pointclouds.py b/pytorch3d/structures/pointclouds.py index eaf03bdc..db5252b5 100644 --- a/pytorch3d/structures/pointclouds.py +++ b/pytorch3d/structures/pointclouds.py @@ -891,7 +891,7 @@ class Pointclouds: ): if n_points > max_: keep_np = np.random.choice(n_points, max_, replace=False) - keep = torch.tensor(keep_np).to(points.device) + keep = torch.tensor(keep_np, device=points.device, dtype=torch.int64) points = points[keep] if features is not None: features = features[keep]