mirror of
https://github.com/facebookresearch/pytorch3d.git
synced 2025-12-21 14:50:36 +08:00
suppress errors in vision - batch 1
Summary: This diff is auto-generated to upgrade the Pyre version and suppress errors in vision. The upgrade will affect Pyre local configurations in the following directories: ``` vision/ale/search vision/fair/fvcore vision/fair/pytorch3d vision/ocr/rosetta_hash vision/vogue/personalization ``` Differential Revision: D21688454 fbshipit-source-id: 1f3c3fee42b6da2e162fd0932742ab8c5c96aa45
This commit is contained in:
committed by
Facebook GitHub Bot
parent
d689baac5e
commit
ae68a54f67
@@ -820,6 +820,7 @@ class Meshes(object):
|
||||
|
||||
# NOTE: this is already applying the area weighting as the magnitude
|
||||
# of the cross product is 2 x area of the triangle.
|
||||
# pyre-fixme[16]: `Tensor` has no attribute `index_add`.
|
||||
verts_normals = verts_normals.index_add(
|
||||
0,
|
||||
faces_packed[:, 1],
|
||||
@@ -1392,6 +1393,7 @@ def join_meshes_as_batch(meshes: List[Meshes], include_textures: bool = True):
|
||||
# Meshes objects can be iterated and produce single Meshes. We avoid
|
||||
# letting join_meshes_as_batch(mesh1, mesh2) silently do the wrong thing.
|
||||
raise ValueError("Wrong first argument to join_meshes_as_batch.")
|
||||
# pyre-fixme[10]: Name `mesh` is used but not defined.
|
||||
verts = [v for mesh in meshes for v in mesh.verts_list()]
|
||||
faces = [f for mesh in meshes for f in mesh.faces_list()]
|
||||
if len(meshes) == 0 or not include_textures:
|
||||
|
||||
@@ -63,6 +63,7 @@ def _extend_tensor(input_tensor: torch.Tensor, N: int) -> torch.Tensor:
|
||||
input_tensor: torch.Tensor with ndim > 2 representing a batched input.
|
||||
N: number of times to extend each element of the batch.
|
||||
"""
|
||||
# pyre-fixme[16]: `Tensor` has no attribute `ndim`.
|
||||
if input_tensor.ndim < 2:
|
||||
raise ValueError("Input tensor must have ndimensions >= 2.")
|
||||
B = input_tensor.shape[0]
|
||||
@@ -98,6 +99,7 @@ class Textures(object):
|
||||
and the packed/list representations are computed on the fly and
|
||||
not cached.
|
||||
"""
|
||||
# pyre-fixme[16]: `Tensor` has no attribute `ndim`.
|
||||
if faces_uvs is not None and faces_uvs.ndim != 3:
|
||||
msg = "Expected faces_uvs to be of shape (N, F, 3); got %r"
|
||||
raise ValueError(msg % repr(faces_uvs.shape))
|
||||
@@ -108,8 +110,10 @@ class Textures(object):
|
||||
msg = "Expected verts_rgb to be of shape (N, V, 3); got %r"
|
||||
raise ValueError(msg % repr(verts_rgb.shape))
|
||||
if maps is not None:
|
||||
# pyre-fixme[16]: `List` has no attribute `ndim`.
|
||||
if torch.is_tensor(maps) and maps.ndim != 4:
|
||||
msg = "Expected maps to be of shape (N, H, W, 3); got %r"
|
||||
# pyre-fixme[16]: `List` has no attribute `shape`.
|
||||
raise ValueError(msg % repr(maps.shape))
|
||||
elif isinstance(maps, list):
|
||||
maps = _pad_texture_maps(maps)
|
||||
@@ -155,20 +159,27 @@ class Textures(object):
|
||||
return other
|
||||
|
||||
def faces_uvs_padded(self) -> torch.Tensor:
|
||||
# pyre-fixme[7]: Expected `Tensor` but got `Optional[torch.Tensor]`.
|
||||
return self._faces_uvs_padded
|
||||
|
||||
def faces_uvs_list(self) -> Union[List[torch.Tensor], None]:
|
||||
if self._faces_uvs_padded is None:
|
||||
return None
|
||||
return padded_to_list(
|
||||
self._faces_uvs_padded, split_size=self._num_faces_per_mesh
|
||||
# pyre-fixme[6]: Expected `Tensor` for 1st param but got
|
||||
# `Optional[torch.Tensor]`.
|
||||
self._faces_uvs_padded,
|
||||
split_size=self._num_faces_per_mesh,
|
||||
)
|
||||
|
||||
def faces_uvs_packed(self) -> Union[torch.Tensor, None]:
|
||||
if self._faces_uvs_padded is None:
|
||||
return None
|
||||
return padded_to_packed(
|
||||
self._faces_uvs_padded, split_size=self._num_faces_per_mesh
|
||||
# pyre-fixme[6]: Expected `Tensor` for 1st param but got
|
||||
# `Optional[torch.Tensor]`.
|
||||
self._faces_uvs_padded,
|
||||
split_size=self._num_faces_per_mesh,
|
||||
)
|
||||
|
||||
def verts_uvs_padded(self) -> Union[torch.Tensor, None]:
|
||||
@@ -182,6 +193,8 @@ class Textures(object):
|
||||
# each face so the num_verts_uvs_per_mesh
|
||||
# may be different from num_verts_per_mesh.
|
||||
# Therefore don't use any split_size.
|
||||
# pyre-fixme[6]: Expected `Tensor` for 1st param but got
|
||||
# `Optional[torch.Tensor]`.
|
||||
return padded_to_list(self._verts_uvs_padded)
|
||||
|
||||
def verts_uvs_packed(self) -> Union[torch.Tensor, None]:
|
||||
@@ -192,6 +205,8 @@ class Textures(object):
|
||||
# each face so the num_verts_uvs_per_mesh
|
||||
# may be different from num_verts_per_mesh.
|
||||
# Therefore don't use any split_size.
|
||||
# pyre-fixme[6]: Expected `Tensor` for 1st param but got
|
||||
# `Optional[torch.Tensor]`.
|
||||
return padded_to_packed(self._verts_uvs_padded)
|
||||
|
||||
def verts_rgb_padded(self) -> Union[torch.Tensor, None]:
|
||||
@@ -201,18 +216,26 @@ class Textures(object):
|
||||
if self._verts_rgb_padded is None:
|
||||
return None
|
||||
return padded_to_list(
|
||||
self._verts_rgb_padded, split_size=self._num_verts_per_mesh
|
||||
# pyre-fixme[6]: Expected `Tensor` for 1st param but got
|
||||
# `Optional[torch.Tensor]`.
|
||||
self._verts_rgb_padded,
|
||||
split_size=self._num_verts_per_mesh,
|
||||
)
|
||||
|
||||
def verts_rgb_packed(self) -> Union[torch.Tensor, None]:
|
||||
if self._verts_rgb_padded is None:
|
||||
return None
|
||||
return padded_to_packed(
|
||||
self._verts_rgb_padded, split_size=self._num_verts_per_mesh
|
||||
# pyre-fixme[6]: Expected `Tensor` for 1st param but got
|
||||
# `Optional[torch.Tensor]`.
|
||||
self._verts_rgb_padded,
|
||||
split_size=self._num_verts_per_mesh,
|
||||
)
|
||||
|
||||
# Currently only the padded maps are used.
|
||||
def maps_padded(self) -> Union[torch.Tensor, None]:
|
||||
# pyre-fixme[7]: Expected `Optional[torch.Tensor]` but got `Union[None,
|
||||
# List[typing.Any], torch.Tensor]`.
|
||||
return self._maps_padded
|
||||
|
||||
def extend(self, N: int) -> "Textures":
|
||||
@@ -234,13 +257,21 @@ class Textures(object):
|
||||
v is not None
|
||||
for v in [self._faces_uvs_padded, self._verts_uvs_padded, self._maps_padded]
|
||||
):
|
||||
# pyre-fixme[6]: Expected `Tensor` for 1st param but got
|
||||
# `Optional[torch.Tensor]`.
|
||||
new_verts_uvs = _extend_tensor(self._verts_uvs_padded, N)
|
||||
# pyre-fixme[6]: Expected `Tensor` for 1st param but got
|
||||
# `Optional[torch.Tensor]`.
|
||||
new_faces_uvs = _extend_tensor(self._faces_uvs_padded, N)
|
||||
# pyre-fixme[6]: Expected `Tensor` for 1st param but got `Union[None,
|
||||
# List[typing.Any], torch.Tensor]`.
|
||||
new_maps = _extend_tensor(self._maps_padded, N)
|
||||
return self.__class__(
|
||||
verts_uvs=new_verts_uvs, faces_uvs=new_faces_uvs, maps=new_maps
|
||||
)
|
||||
elif self._verts_rgb_padded is not None:
|
||||
# pyre-fixme[6]: Expected `Tensor` for 1st param but got
|
||||
# `Optional[torch.Tensor]`.
|
||||
new_verts_rgb = _extend_tensor(self._verts_rgb_padded, N)
|
||||
return self.__class__(verts_rgb=new_verts_rgb)
|
||||
else:
|
||||
|
||||
@@ -48,6 +48,7 @@ def list_to_padded(
|
||||
)
|
||||
for i, y in enumerate(x):
|
||||
if len(y) > 0:
|
||||
# pyre-fixme[16]: `Tensor` has no attribute `ndim`.
|
||||
if y.ndim != 2:
|
||||
raise ValueError("Supports only 2-dimensional tensor items")
|
||||
x_padded[i, : y.shape[0], : y.shape[1]] = y
|
||||
@@ -69,6 +70,7 @@ def padded_to_list(x: torch.Tensor, split_size: Union[list, tuple, None] = None)
|
||||
Returns:
|
||||
x_list: a list of tensors
|
||||
"""
|
||||
# pyre-fixme[16]: `Tensor` has no attribute `ndim`.
|
||||
if x.ndim != 3:
|
||||
raise ValueError("Supports only 3-dimensional input tensors")
|
||||
x_list = list(x.unbind(0))
|
||||
@@ -145,6 +147,7 @@ def packed_to_list(x: torch.Tensor, split_size: Union[list, int]):
|
||||
Returns:
|
||||
x_list: A list of Tensors
|
||||
"""
|
||||
# pyre-fixme[16]: `Tensor` has no attribute `split`.
|
||||
return x.split(split_size, dim=0)
|
||||
|
||||
|
||||
@@ -174,6 +177,7 @@ def padded_to_packed(
|
||||
Returns:
|
||||
x_packed: a packed tensor.
|
||||
"""
|
||||
# pyre-fixme[16]: `Tensor` has no attribute `ndim`.
|
||||
if x.ndim != 3:
|
||||
raise ValueError("Supports only 3-dimensional input tensors")
|
||||
|
||||
@@ -189,15 +193,19 @@ def padded_to_packed(
|
||||
|
||||
# Convert to packed using pad value
|
||||
if pad_value is not None:
|
||||
# pyre-fixme[16]: `ByteTensor` has no attribute `any`.
|
||||
mask = x_packed.ne(pad_value).any(-1)
|
||||
x_packed = x_packed[mask]
|
||||
return x_packed
|
||||
|
||||
# Convert to packed using split sizes
|
||||
# pyre-fixme[6]: Expected `Sized` for 1st param but got `Union[None,
|
||||
# List[typing.Any], typing.Tuple[typing.Any, ...]]`.
|
||||
N = len(split_size)
|
||||
if x.shape[0] != N:
|
||||
raise ValueError("Split size must be of same length as inputs first dimension")
|
||||
|
||||
# pyre-fixme[16]: `None` has no attribute `__iter__`.
|
||||
if not all(isinstance(i, int) for i in split_size):
|
||||
raise ValueError(
|
||||
"Support only 1-dimensional unbinded tensor. \
|
||||
@@ -207,6 +215,8 @@ def padded_to_packed(
|
||||
padded_to_packed_idx = torch.cat(
|
||||
[
|
||||
torch.arange(v, dtype=torch.int64, device=x.device) + i * M
|
||||
# pyre-fixme[6]: Expected `Iterable[Variable[_T]]` for 1st param but got
|
||||
# `Union[None, List[typing.Any], typing.Tuple[typing.Any, ...]]`.
|
||||
for (i, v) in enumerate(split_size)
|
||||
],
|
||||
dim=0,
|
||||
|
||||
Reference in New Issue
Block a user