mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-19 22:00:35 +08:00
replace view with reshape, check for nans
Summary: Replace view with reshape, add check for nans before mesh sampling Reviewed By: nikhilaravi Differential Revision: D20548456 fbshipit-source-id: c4e1b88e033ecb8f0f3a8f3a33a04ce13a5b5043
This commit is contained in:
committed by
Facebook GitHub Bot
parent
53599770dd
commit
6c48ff6ad9
@@ -291,6 +291,26 @@ class TestSamplePoints(unittest.TestCase):
|
||||
if sampled_weights.min() <= 0:
|
||||
return False
|
||||
return True
|
||||
|
||||
def test_verts_nan(self):
|
||||
num_verts = 30
|
||||
num_faces = 50
|
||||
for device in ["cpu", "cuda:0"]:
|
||||
for invalid in ["nan", "inf"]:
|
||||
verts = torch.rand(
|
||||
(num_verts, 3), dtype=torch.float32, device=device
|
||||
)
|
||||
# randomly assign an invalid type
|
||||
verts[torch.randperm(num_verts)[:10]] = float(invalid)
|
||||
faces = torch.randint(
|
||||
num_verts, size=(num_faces, 3), dtype=torch.int64, device=device
|
||||
)
|
||||
meshes = Meshes(verts=[verts], faces=[faces])
|
||||
|
||||
with self.assertRaisesRegex(ValueError, "Meshes contain nan or inf."):
|
||||
sample_points_from_meshes(
|
||||
meshes, num_samples=100, return_normals=True
|
||||
)
|
||||
|
||||
@staticmethod
|
||||
def sample_points_with_init(
|
||||
|
||||
Reference in New Issue
Block a user