mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-19 05:40:34 +08:00
add min_triangle_area argument to IsInsideTriangle
Summary: 1. changed IsInsideTriangle in geometry_utils to take in min_triangle_area parameter instead of hardcoded value 2. updated point_mesh_cpu.cpp and point_mesh_cuda.[h/cu] to adapt to changes in geometry_utils function signatures 3. updated point_mesh_distance.py and test_point_mesh_distance.py to modify _C. calls Reviewed By: bottler Differential Revision: D34459764 fbshipit-source-id: 0549e78713c6d68f03d85fb597a13dd88e09b686
This commit is contained in:
committed by
Facebook GitHub Bot
parent
4d043fc9ac
commit
471b126818
@@ -23,6 +23,10 @@ class TestPointMeshDistance(TestCaseMixin, unittest.TestCase):
|
||||
def eps():
|
||||
return 1e-8
|
||||
|
||||
@staticmethod
|
||||
def min_triangle_area():
|
||||
return 5e-3
|
||||
|
||||
@staticmethod
|
||||
def init_meshes_clouds(
|
||||
batch_size: int = 10,
|
||||
@@ -563,8 +567,12 @@ class TestPointMeshDistance(TestCaseMixin, unittest.TestCase):
|
||||
grad_tris_naive = tris.grad.cpu()
|
||||
|
||||
# Cuda Forward Implementation
|
||||
dists_cuda = _C.point_face_array_dist_forward(points, tris)
|
||||
dists_cpu = _C.point_face_array_dist_forward(points_cpu, tris_cpu)
|
||||
dists_cuda = _C.point_face_array_dist_forward(
|
||||
points, tris, TestPointMeshDistance.min_triangle_area()
|
||||
)
|
||||
dists_cpu = _C.point_face_array_dist_forward(
|
||||
points_cpu, tris_cpu, TestPointMeshDistance.min_triangle_area()
|
||||
)
|
||||
|
||||
# Compare
|
||||
self.assertClose(dists_naive.cpu(), dists_cuda.cpu())
|
||||
@@ -572,10 +580,13 @@ class TestPointMeshDistance(TestCaseMixin, unittest.TestCase):
|
||||
|
||||
# CUDA Backward Implementation
|
||||
grad_points_cuda, grad_tris_cuda = _C.point_face_array_dist_backward(
|
||||
points, tris, grad_dists
|
||||
points, tris, grad_dists, TestPointMeshDistance.min_triangle_area()
|
||||
)
|
||||
grad_points_cpu, grad_tris_cpu = _C.point_face_array_dist_backward(
|
||||
points_cpu, tris_cpu, grad_dists.cpu()
|
||||
points_cpu,
|
||||
tris_cpu,
|
||||
grad_dists.cpu(),
|
||||
TestPointMeshDistance.min_triangle_area(),
|
||||
)
|
||||
|
||||
# Compare
|
||||
@@ -615,12 +626,21 @@ class TestPointMeshDistance(TestCaseMixin, unittest.TestCase):
|
||||
|
||||
# Cuda Implementation: forward
|
||||
dists_cuda, idx_cuda = _C.point_face_dist_forward(
|
||||
points_packed, points_first_idx, faces_packed, faces_first_idx, max_p
|
||||
points_packed,
|
||||
points_first_idx,
|
||||
faces_packed,
|
||||
faces_first_idx,
|
||||
max_p,
|
||||
TestPointMeshDistance.min_triangle_area(),
|
||||
)
|
||||
|
||||
# Cuda Implementation: backward
|
||||
grad_points_cuda, grad_faces_cuda = _C.point_face_dist_backward(
|
||||
points_packed, faces_packed, idx_cuda, grad_dists
|
||||
points_packed,
|
||||
faces_packed,
|
||||
idx_cuda,
|
||||
grad_dists,
|
||||
TestPointMeshDistance.min_triangle_area(),
|
||||
)
|
||||
|
||||
# Cpu Implementation: forward
|
||||
@@ -630,12 +650,17 @@ class TestPointMeshDistance(TestCaseMixin, unittest.TestCase):
|
||||
faces_packed.cpu(),
|
||||
faces_first_idx.cpu(),
|
||||
max_p,
|
||||
TestPointMeshDistance.min_triangle_area(),
|
||||
)
|
||||
|
||||
# Cpu Implementation: backward
|
||||
# Note that using idx_cpu doesn't pass - there seems to be a problem with tied results.
|
||||
grad_points_cpu, grad_faces_cpu = _C.point_face_dist_backward(
|
||||
points_packed.cpu(), faces_packed.cpu(), idx_cuda.cpu(), grad_dists.cpu()
|
||||
points_packed.cpu(),
|
||||
faces_packed.cpu(),
|
||||
idx_cuda.cpu(),
|
||||
grad_dists.cpu(),
|
||||
TestPointMeshDistance.min_triangle_area(),
|
||||
)
|
||||
|
||||
# Naive Implementation: forward
|
||||
@@ -716,12 +741,21 @@ class TestPointMeshDistance(TestCaseMixin, unittest.TestCase):
|
||||
|
||||
# Cuda Implementation: forward
|
||||
dists_cuda, idx_cuda = _C.face_point_dist_forward(
|
||||
points_packed, points_first_idx, faces_packed, faces_first_idx, max_f
|
||||
points_packed,
|
||||
points_first_idx,
|
||||
faces_packed,
|
||||
faces_first_idx,
|
||||
max_f,
|
||||
TestPointMeshDistance.min_triangle_area(),
|
||||
)
|
||||
|
||||
# Cuda Implementation: backward
|
||||
grad_points_cuda, grad_faces_cuda = _C.face_point_dist_backward(
|
||||
points_packed, faces_packed, idx_cuda, grad_dists
|
||||
points_packed,
|
||||
faces_packed,
|
||||
idx_cuda,
|
||||
grad_dists,
|
||||
TestPointMeshDistance.min_triangle_area(),
|
||||
)
|
||||
|
||||
# Cpu Implementation: forward
|
||||
@@ -731,11 +765,16 @@ class TestPointMeshDistance(TestCaseMixin, unittest.TestCase):
|
||||
faces_packed.cpu(),
|
||||
faces_first_idx.cpu(),
|
||||
max_f,
|
||||
TestPointMeshDistance.min_triangle_area(),
|
||||
)
|
||||
|
||||
# Cpu Implementation: backward
|
||||
grad_points_cpu, grad_faces_cpu = _C.face_point_dist_backward(
|
||||
points_packed.cpu(), faces_packed.cpu(), idx_cpu, grad_dists.cpu()
|
||||
points_packed.cpu(),
|
||||
faces_packed.cpu(),
|
||||
idx_cpu,
|
||||
grad_dists.cpu(),
|
||||
TestPointMeshDistance.min_triangle_area(),
|
||||
)
|
||||
|
||||
# Naive Implementation: forward
|
||||
|
||||
Reference in New Issue
Block a user