mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2026-02-26 16:26:00 +08:00
fbcode/vision/fair/pytorch3d/pytorch3d/ops/laplacian_matrices.py
Reviewed By: bottler Differential Revision: D93708383 fbshipit-source-id: 7576f0c9800ed3d28795e521be5c63799b7e6676
This commit is contained in:
committed by
meta-codesync[bot]
parent
42d66c1145
commit
3aadd19a2b
@@ -55,11 +55,9 @@ def laplacian(verts: torch.Tensor, edges: torch.Tensor) -> torch.Tensor:
|
|||||||
# We construct the Laplacian matrix by adding the non diagonal values
|
# We construct the Laplacian matrix by adding the non diagonal values
|
||||||
# i.e. L[i, j] = 1 ./ deg(i) if (i, j) is an edge
|
# i.e. L[i, j] = 1 ./ deg(i) if (i, j) is an edge
|
||||||
deg0 = deg[e0]
|
deg0 = deg[e0]
|
||||||
# pyre-fixme[58]: `/` is not supported for operand types `float` and `Tensor`.
|
deg0 = torch.where(deg0 > 0.0, torch.reciprocal(deg0), deg0)
|
||||||
deg0 = torch.where(deg0 > 0.0, 1.0 / deg0, deg0)
|
|
||||||
deg1 = deg[e1]
|
deg1 = deg[e1]
|
||||||
# pyre-fixme[58]: `/` is not supported for operand types `float` and `Tensor`.
|
deg1 = torch.where(deg1 > 0.0, torch.reciprocal(deg1), deg1)
|
||||||
deg1 = torch.where(deg1 > 0.0, 1.0 / deg1, deg1)
|
|
||||||
val = torch.cat([deg0, deg1])
|
val = torch.cat([deg0, deg1])
|
||||||
L = torch.sparse_coo_tensor(idx, val, (V, V), dtype=torch.float32)
|
L = torch.sparse_coo_tensor(idx, val, (V, V), dtype=torch.float32)
|
||||||
|
|
||||||
@@ -137,8 +135,7 @@ def cot_laplacian(
|
|||||||
val = torch.stack([area] * 3, dim=1).view(-1)
|
val = torch.stack([area] * 3, dim=1).view(-1)
|
||||||
inv_areas.scatter_add_(0, idx, val)
|
inv_areas.scatter_add_(0, idx, val)
|
||||||
idx = inv_areas > 0
|
idx = inv_areas > 0
|
||||||
# pyre-fixme[58]: `/` is not supported for operand types `float` and `Tensor`.
|
inv_areas[idx] = torch.reciprocal(inv_areas[idx])
|
||||||
inv_areas[idx] = 1.0 / inv_areas[idx]
|
|
||||||
inv_areas = inv_areas.view(-1, 1)
|
inv_areas = inv_areas.view(-1, 1)
|
||||||
|
|
||||||
return L, inv_areas
|
return L, inv_areas
|
||||||
|
|||||||
Reference in New Issue
Block a user