From 14f015d8bf01e8c870b26a28aebbe97460cc398f Mon Sep 17 00:00:00 2001 From: Adly Templeton Date: Wed, 2 Sep 2020 06:51:15 -0700 Subject: [PATCH] Add pyre typeshed information for Tensor.ndim and nn.ConvTranspose2d Summary: Adding some appropriate methods into pyre typeshed. Removing corresponding pyre-ignore and pyre-fixme messages. Differential Revision: D22949138 fbshipit-source-id: add8acdd4611ab698954868832594d062cd58f88 --- pytorch3d/loss/chamfer.py | 1 - pytorch3d/renderer/mesh/textures.py | 6 +----- pytorch3d/structures/utils.py | 3 --- pytorch3d/transforms/transform3d.py | 1 - 4 files changed, 1 insertion(+), 10 deletions(-) diff --git a/pytorch3d/loss/chamfer.py b/pytorch3d/loss/chamfer.py index f9918ddb..a4cf9d92 100644 --- a/pytorch3d/loss/chamfer.py +++ b/pytorch3d/loss/chamfer.py @@ -41,7 +41,6 @@ def _handle_pointcloud_input( lengths = points.num_points_per_cloud() normals = points.normals_padded() # either a tensor or None elif torch.is_tensor(points): - # pyre-fixme[16]: `Tensor` has no attribute `ndim`. if points.ndim != 3: raise ValueError("Expected points to be of shape (N, P, D)") X = points diff --git a/pytorch3d/renderer/mesh/textures.py b/pytorch3d/renderer/mesh/textures.py index cccb3d75..3c9915c0 100644 --- a/pytorch3d/renderer/mesh/textures.py +++ b/pytorch3d/renderer/mesh/textures.py @@ -52,7 +52,6 @@ def _list_to_padded_wrapper( x_padded: tensor consisting of padded input tensors """ N = len(x) - # pyre-fixme[16]: `Tensor` has no attribute `ndim`. dims = x[0].ndim reshape_dims = x[0].shape[1:] D = torch.prod(torch.tensor(reshape_dims)).item() @@ -598,7 +597,6 @@ class TexturesUV(TexturesBase): self.align_corners = align_corners if isinstance(faces_uvs, (list, tuple)): for fv in faces_uvs: - # pyre-fixme[16]: `Tensor` has no attribute `ndim`. if fv.ndim != 2 or fv.shape[-1] != 3: msg = "Expected faces_uvs to be of shape (F, 3); got %r" raise ValueError(msg % repr(fv.shape)) @@ -1129,9 +1127,7 @@ class TexturesVertex(TexturesBase): """ if isinstance(verts_features, (tuple, list)): correct_shape = all( - # pyre-fixme[16]: `Tensor` has no attribute `ndim`. - (torch.is_tensor(v) and v.ndim == 2) - for v in verts_features + (torch.is_tensor(v) and v.ndim == 2) for v in verts_features ) if not correct_shape: raise ValueError( diff --git a/pytorch3d/structures/utils.py b/pytorch3d/structures/utils.py index a130db93..5da55d70 100644 --- a/pytorch3d/structures/utils.py +++ b/pytorch3d/structures/utils.py @@ -48,7 +48,6 @@ 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 @@ -70,7 +69,6 @@ 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") @@ -178,7 +176,6 @@ 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") diff --git a/pytorch3d/transforms/transform3d.py b/pytorch3d/transforms/transform3d.py index b3bc2f44..695af174 100644 --- a/pytorch3d/transforms/transform3d.py +++ b/pytorch3d/transforms/transform3d.py @@ -155,7 +155,6 @@ class Transform3d: if matrix is None: self._matrix = torch.eye(4, dtype=dtype, device=device).view(1, 4, 4) else: - # pyre-fixme[16]: `Tensor` has no attribute `ndim`. if matrix.ndim not in (2, 3): raise ValueError('"matrix" has to be a 2- or a 3-dimensional tensor.') if matrix.shape[-2] != 4 or matrix.shape[-1] != 4: