From bf129e0b03b39794b0ce2c3fa8e47dcef7b18360 Mon Sep 17 00:00:00 2001 From: Naoya Muramatsu Date: Thu, 31 Oct 2024 20:37:38 +0200 Subject: [PATCH] replace torch.sparse.SparseTensor to torch.sparse_coo_tensor --- pytorch3d/ops/laplacian_matrices.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/pytorch3d/ops/laplacian_matrices.py b/pytorch3d/ops/laplacian_matrices.py index 6400923f..a7e9b49a 100644 --- a/pytorch3d/ops/laplacian_matrices.py +++ b/pytorch3d/ops/laplacian_matrices.py @@ -48,7 +48,7 @@ def laplacian(verts: torch.Tensor, edges: torch.Tensor) -> torch.Tensor: # A[e0, e1] = 1 & A[e1, e0] = 1 ones = torch.ones(idx.shape[1], dtype=torch.float32, device=verts.device) # pyre-fixme[16]: Module `sparse` has no attribute `FloatTensor`. - A = torch.sparse.FloatTensor(idx, ones, (V, V)) + A = torch.sparse_coo_tensor(idx, ones, (V, V)) # the sum of i-th row of A gives the degree of the i-th vertex deg = torch.sparse.sum(A, dim=1).to_dense() @@ -63,14 +63,14 @@ def laplacian(verts: torch.Tensor, edges: torch.Tensor) -> torch.Tensor: deg1 = torch.where(deg1 > 0.0, 1.0 / deg1, deg1) val = torch.cat([deg0, deg1]) # pyre-fixme[16]: Module `sparse` has no attribute `FloatTensor`. - L = torch.sparse.FloatTensor(idx, val, (V, V)) + L = torch.sparse_coo_tensor(idx, val, (V, V)) # Then we add the diagonal values L[i, i] = -1. idx = torch.arange(V, device=verts.device) idx = torch.stack([idx, idx], dim=0) ones = torch.ones(idx.shape[1], dtype=torch.float32, device=verts.device) # pyre-fixme[16]: Module `sparse` has no attribute `FloatTensor`. - L -= torch.sparse.FloatTensor(idx, ones, (V, V)) + L -= torch.sparse_coo_tensor(idx, ones, (V, V)) return L @@ -127,7 +127,7 @@ def cot_laplacian( jj = faces[:, [2, 0, 1]] idx = torch.stack([ii, jj], dim=0).view(2, F * 3) # pyre-fixme[16]: Module `sparse` has no attribute `FloatTensor`. - L = torch.sparse.FloatTensor(idx, cot.view(-1), (V, V)) + L = torch.sparse_coo_tensor(idx, cot.view(-1), (V, V)) # Make it symmetric; this means we are also setting # L[v2, v1] = cota @@ -176,7 +176,7 @@ def norm_laplacian( V = verts.shape[0] # pyre-fixme[16]: Module `sparse` has no attribute `FloatTensor`. - L = torch.sparse.FloatTensor(e01, w01, (V, V)) + L = torch.sparse_coo_tensor(e01, w01, (V, V)) L = L + L.t() return L