mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-21 23:00:34 +08:00
validate lengths in chamfer and farthest_points
Summary: Fixes #1326 Reviewed By: kjchalup Differential Revision: D39259697 fbshipit-source-id: 51392f4cc4a956165a62901cb115fcefe0e17277
This commit is contained in:
committed by
Facebook GitHub Bot
parent
6e25fe8cb3
commit
cb7bd33e7f
@@ -56,9 +56,11 @@ def sample_farthest_points(
|
||||
# Validate inputs
|
||||
if lengths is None:
|
||||
lengths = torch.full((N,), P, dtype=torch.int64, device=device)
|
||||
|
||||
if lengths.shape != (N,):
|
||||
raise ValueError("points and lengths must have same batch dimension.")
|
||||
else:
|
||||
if lengths.shape != (N,):
|
||||
raise ValueError("points and lengths must have same batch dimension.")
|
||||
if lengths.max() > P:
|
||||
raise ValueError("A value in lengths was too large.")
|
||||
|
||||
# TODO: support providing K as a ratio of the total number of points instead of as an int
|
||||
if isinstance(K, int):
|
||||
@@ -107,9 +109,11 @@ def sample_farthest_points_naive(
|
||||
# Validate inputs
|
||||
if lengths is None:
|
||||
lengths = torch.full((N,), P, dtype=torch.int64, device=device)
|
||||
|
||||
if lengths.shape[0] != N:
|
||||
raise ValueError("points and lengths must have same batch dimension.")
|
||||
else:
|
||||
if lengths.shape != (N,):
|
||||
raise ValueError("points and lengths must have same batch dimension.")
|
||||
if lengths.max() > P:
|
||||
raise ValueError("Invalid lengths.")
|
||||
|
||||
# TODO: support providing K as a ratio of the total number of points instead of as an int
|
||||
if isinstance(K, int):
|
||||
|
||||
Reference in New Issue
Block a user