Reshape for faces_packed_to_edges_packed

Summary:
As pointed out in #328, we had an indexing operation where a reshape would do and be faster. The resulting faces_packed_to_edges_packed is no longer contiguous.

Also fix a use of faces_packed_to_edges_packed which might modify the object unintentionally.

Reviewed By: theschnitz

Differential Revision: D24390292

fbshipit-source-id: 225677d8fcc1d6b76efad7706718ecdb5182ffe1
This commit is contained in:
Jeremy Reizenstein 2020-10-20 13:44:41 -07:00 committed by Facebook GitHub Bot
parent 4cfac7c79c
commit abd390319c
2 changed files with 4 additions and 5 deletions

View File

@ -103,8 +103,9 @@ class SubdivideMeshes(nn.Module):
verts_packed = meshes.verts_packed()
with torch.no_grad():
faces_packed = meshes.faces_packed()
faces_packed_to_edges_packed = meshes.faces_packed_to_edges_packed()
faces_packed_to_edges_packed += verts_packed.shape[0]
faces_packed_to_edges_packed = (
meshes.faces_packed_to_edges_packed() + verts_packed.shape[0]
)
f0 = torch.stack(
[

View File

@ -1035,9 +1035,7 @@ class Meshes(object):
self._edges_packed = torch.stack([u // V, u % V], dim=1)
self._edges_packed_to_mesh_idx = edge_to_mesh[unique_idx]
face_to_edge = torch.arange(3 * F).view(3, F).t()
face_to_edge = inverse_idxs[face_to_edge]
self._faces_packed_to_edges_packed = face_to_edge
self._faces_packed_to_edges_packed = inverse_idxs.reshape(3, F).t()
# Compute number of edges per mesh
num_edges_per_mesh = torch.zeros(self._N, dtype=torch.int32, device=self.device)