mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-20 22:30:35 +08:00
Take care with single integers on gpu
Summary:
Pytorch seems to be becoming stricter about integer tensors of shape `(1,)` on GPU and not allowing them to be used as `int`s. For example the following no longer works on pytorch master,
foo = torch.tensor([3, 5, 3], device="cuda:0")
torch.arange(10) + foo[0]
because this is the sum of tensors on different devices.
Here fix tests which recently broke because of this.
Reviewed By: nikhilaravi
Differential Revision: D21929745
fbshipit-source-id: 25374f70468d1c895372766f1a9dd61df0833957
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d0e7426a06
commit
7f1e63aed1
@@ -329,11 +329,11 @@ class Meshes(object):
|
||||
self._num_verts_per_mesh = torch.tensor(
|
||||
[len(v) for v in self._verts_list], device=self.device
|
||||
)
|
||||
self._V = self._num_verts_per_mesh.max()
|
||||
self._V = int(self._num_verts_per_mesh.max())
|
||||
self._num_faces_per_mesh = torch.tensor(
|
||||
[len(f) for f in self._faces_list], device=self.device
|
||||
)
|
||||
self._F = self._num_faces_per_mesh.max()
|
||||
self._F = int(self._num_faces_per_mesh.max())
|
||||
self.valid = torch.tensor(
|
||||
[
|
||||
len(v) > 0 and len(f) > 0
|
||||
@@ -370,7 +370,7 @@ class Meshes(object):
|
||||
# as long as the faces index correspond to the right vertices.
|
||||
|
||||
self.valid = self._num_faces_per_mesh > 0
|
||||
self._F = self._num_faces_per_mesh.max()
|
||||
self._F = int(self._num_faces_per_mesh.max())
|
||||
if len(self._num_faces_per_mesh.unique()) == 1:
|
||||
self.equisized = True
|
||||
|
||||
|
||||
@@ -189,7 +189,7 @@ class Pointclouds(object):
|
||||
num_points_per_cloud = torch.tensor(
|
||||
[len(p) for p in self._points_list], device=self.device
|
||||
)
|
||||
self._P = num_points_per_cloud.max()
|
||||
self._P = int(num_points_per_cloud.max())
|
||||
self.valid = torch.tensor(
|
||||
[len(p) > 0 for p in self._points_list],
|
||||
dtype=torch.bool,
|
||||
|
||||
Reference in New Issue
Block a user