diff --git a/pytorch3d/io/mtl_io.py b/pytorch3d/io/mtl_io.py index be5e7a72..97f5ba74 100644 --- a/pytorch3d/io/mtl_io.py +++ b/pytorch3d/io/mtl_io.py @@ -51,6 +51,7 @@ def make_mesh_texture_atlas( # Initialize the per face texture map to a white color. # TODO: allow customization of this base color? + # pyre-fixme[16]: `Tensor` has no attribute `new_ones`. atlas = faces_verts_uvs.new_ones(size=(F, R, R, 3)) # Check for empty materials. @@ -63,10 +64,13 @@ def make_mesh_texture_atlas( # will be ignored and a repeating pattern is formed. # Shapenet data uses this format see: # https://shapenet.org/qaforum/index.php?qa=15&qa_1=why-is-the-texture-coordinate-in-the-obj-file-not-in-the-range # noqa: B950 + # pyre-fixme[16]: `ByteTensor` has no attribute `any`. if (faces_verts_uvs > 1).any() or (faces_verts_uvs < 0).any(): msg = "Texture UV coordinates outside the range [0, 1]. \ The integer part will be ignored to form a repeating pattern." warnings.warn(msg) + # pyre-fixme[9]: faces_verts_uvs has type `Tensor`; used as `int`. + # pyre-fixme[6]: Expected `int` for 1st param but got `Tensor`. faces_verts_uvs = faces_verts_uvs % 1 elif texture_wrap == "clamp": # Clamp uv coordinates to the [0, 1] range. @@ -257,6 +261,7 @@ def make_material_atlas( # Meshgrid returns (row, column) i.e (Y, X) # Change order to (X, Y) to make the grid. Y, X = torch.meshgrid(rng, rng) + # pyre-fixme[28]: Unexpected keyword argument `axis`. grid = torch.stack([X, Y], axis=-1) # (R, R, 2) # Grid cells below the diagonal: x + y < R. @@ -269,6 +274,7 @@ def make_material_atlas( # w0, w1 bary[below_diag, slc] = ((grid[below_diag] + 1.0 / 3.0) / R).T # w0, w1 for above diagonal grid cells. + # pyre-fixme[16]: `float` has no attribute `T`. bary[~below_diag, slc] = (((R - 1.0 - grid[~below_diag]) + 2.0 / 3.0) / R).T # w2 = 1. - w0 - w1 bary[..., -1] = 1 - bary[..., :2].sum(dim=-1) diff --git a/pytorch3d/io/obj_io.py b/pytorch3d/io/obj_io.py index b7ab04c5..bf5a0f85 100644 --- a/pytorch3d/io/obj_io.py +++ b/pytorch3d/io/obj_io.py @@ -213,6 +213,8 @@ def load_obj( """ data_dir = "./" if isinstance(f_obj, (str, bytes, os.PathLike)): + # pyre-fixme[6]: Expected `_PathLike[Variable[typing.AnyStr <: [str, + # bytes]]]` for 1st param but got `Union[_PathLike[typing.Any], bytes, str]`. data_dir = os.path.dirname(f_obj) f_obj, new_f = _open_file(f_obj) try: @@ -453,6 +455,8 @@ def _load( material_colors, texture_images, texture_atlas = None, None, None if load_textures: if (len(material_names) > 0) and (f_mtl is not None): + # pyre-fixme[6]: Expected `Union[_PathLike[typing.Any], bytes, str]` for + # 1st param but got `Optional[str]`. if os.path.isfile(f_mtl): # Texture mode uv wrap material_colors, texture_images = load_mtl( diff --git a/pytorch3d/io/utils.py b/pytorch3d/io/utils.py index 969f3005..a66da0f0 100644 --- a/pytorch3d/io/utils.py +++ b/pytorch3d/io/utils.py @@ -30,6 +30,8 @@ def _read_image(file_name: str, format=None): if format not in ["RGB", "BGR"]: raise ValueError("format can only be one of [RGB, BGR]; got %s", format) with PathManager.open(file_name, "rb") as f: + # pyre-fixme[6]: Expected `Union[str, typing.BinaryIO]` for 1st param but + # got `Union[typing.IO[bytes], typing.IO[str]]`. image = Image.open(f) if format is not None: # PIL only supports RGB. First convert to RGB and flip channels diff --git a/pytorch3d/loss/chamfer.py b/pytorch3d/loss/chamfer.py index e963de4a..f9918ddb 100644 --- a/pytorch3d/loss/chamfer.py +++ b/pytorch3d/loss/chamfer.py @@ -41,6 +41,7 @@ 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 @@ -173,6 +174,7 @@ def chamfer_distance( ) if is_x_heterogeneous: + # pyre-fixme[16]: `int` has no attribute `__setitem__`. cham_norm_x[x_mask] = 0.0 if is_y_heterogeneous: cham_norm_y[y_mask] = 0.0 diff --git a/pytorch3d/loss/point_mesh_distance.py b/pytorch3d/loss/point_mesh_distance.py index 0dd2cc2a..4a263c5a 100644 --- a/pytorch3d/loss/point_mesh_distance.py +++ b/pytorch3d/loss/point_mesh_distance.py @@ -65,6 +65,7 @@ class _PointFaceDistance(Function): return grad_points, None, grad_tris, None, None +# pyre-fixme[16]: `_PointFaceDistance` has no attribute `apply`. point_face_distance = _PointFaceDistance.apply @@ -115,6 +116,7 @@ class _FacePointDistance(Function): return grad_points, None, grad_tris, None, None +# pyre-fixme[16]: `_FacePointDistance` has no attribute `apply`. face_point_distance = _FacePointDistance.apply @@ -165,6 +167,7 @@ class _PointEdgeDistance(Function): return grad_points, None, grad_segms, None, None +# pyre-fixme[16]: `_PointEdgeDistance` has no attribute `apply`. point_edge_distance = _PointEdgeDistance.apply @@ -215,6 +218,7 @@ class _EdgePointDistance(Function): return grad_points, None, grad_segms, None, None +# pyre-fixme[16]: `_EdgePointDistance` has no attribute `apply`. edge_point_distance = _EdgePointDistance.apply diff --git a/pytorch3d/ops/cubify.py b/pytorch3d/ops/cubify.py index 2d9810cb..6de5decb 100644 --- a/pytorch3d/ops/cubify.py +++ b/pytorch3d/ops/cubify.py @@ -229,6 +229,7 @@ def cubify(voxels, thresh, device=None, align: str = "topleft") -> Meshes: idlenum = idleverts.cumsum(1) verts_list = [ + # pyre-fixme[16]: `Tensor` has no attribute `index_select`. grid_verts.index_select(0, (idleverts[n] == 0).nonzero(as_tuple=False)[:, 0]) for n in range(N) ] diff --git a/pytorch3d/ops/graph_conv.py b/pytorch3d/ops/graph_conv.py index dd21dfc0..796df24c 100644 --- a/pytorch3d/ops/graph_conv.py +++ b/pytorch3d/ops/graph_conv.py @@ -35,6 +35,7 @@ class GraphConv(nn.Module): if init == "normal": nn.init.normal_(self.w0.weight, mean=0, std=0.01) nn.init.normal_(self.w1.weight, mean=0, std=0.01) + # pyre-fixme[16]: Optional type has no attribute `data`. self.w0.bias.data.zero_() self.w1.bias.data.zero_() elif init == "zero": @@ -115,6 +116,7 @@ def gather_scatter_python(input, edges, directed: bool = False): idx0 = edges[:, 0].view(num_edges, 1).expand(num_edges, input_feature_dim) idx1 = edges[:, 1].view(num_edges, 1).expand(num_edges, input_feature_dim) + # pyre-fixme[16]: `Tensor` has no attribute `scatter_add`. output = output.scatter_add(0, idx0, input.gather(0, idx1)) if not directed: output = output.scatter_add(0, idx1, input.gather(0, idx0)) @@ -167,4 +169,5 @@ class GatherScatter(Function): return grad_input, grad_edges, grad_directed +# pyre-fixme[16]: `GatherScatter` has no attribute `apply`. gather_scatter = GatherScatter.apply diff --git a/pytorch3d/ops/knn.py b/pytorch3d/ops/knn.py index cdd02e46..a1969c2b 100644 --- a/pytorch3d/ops/knn.py +++ b/pytorch3d/ops/knn.py @@ -157,6 +157,7 @@ def knn_points( if lengths2 is None: lengths2 = torch.full((p1.shape[0],), P2, dtype=torch.int64, device=p1.device) + # pyre-fixme[16]: `_knn_points` has no attribute `apply`. p1_dists, p1_idx = _knn_points.apply(p1, p2, lengths1, lengths2, K, version) p2_nn = None diff --git a/pytorch3d/ops/mesh_face_areas_normals.py b/pytorch3d/ops/mesh_face_areas_normals.py index 68dcc13c..d58ad0b6 100644 --- a/pytorch3d/ops/mesh_face_areas_normals.py +++ b/pytorch3d/ops/mesh_face_areas_normals.py @@ -59,4 +59,5 @@ class _MeshFaceAreasNormals(Function): return grad_verts, None +# pyre-fixme[16]: `_MeshFaceAreasNormals` has no attribute `apply`. mesh_face_areas_normals = _MeshFaceAreasNormals.apply diff --git a/pytorch3d/ops/sample_points_from_meshes.py b/pytorch3d/ops/sample_points_from_meshes.py index 7236c42b..44350a65 100644 --- a/pytorch3d/ops/sample_points_from_meshes.py +++ b/pytorch3d/ops/sample_points_from_meshes.py @@ -120,4 +120,6 @@ def _rand_barycentric_coords( w0 = 1.0 - u_sqrt w1 = u_sqrt * (1.0 - v) w2 = u_sqrt * v + # pyre-fixme[7]: Expected `Tuple[torch.Tensor, torch.Tensor, torch.Tensor]` but + # got `Tuple[float, typing.Any, typing.Any]`. return w0, w1, w2 diff --git a/pytorch3d/ops/vert_align.py b/pytorch3d/ops/vert_align.py index 1ec42053..c53a1fb7 100644 --- a/pytorch3d/ops/vert_align.py +++ b/pytorch3d/ops/vert_align.py @@ -96,6 +96,7 @@ def vert_align( .view(-1, 1) .expand(-1, feats_sampled.shape[-1]) ) + # pyre-fixme[16]: `Tensor` has no attribute `gather`. feats_sampled = feats_sampled.gather(0, idx) # (sum(V), C) return feats_sampled diff --git a/pytorch3d/renderer/blending.py b/pytorch3d/renderer/blending.py index ea67c5f1..87d8f59b 100644 --- a/pytorch3d/renderer/blending.py +++ b/pytorch3d/renderer/blending.py @@ -150,7 +150,10 @@ def softmax_rgb_blend( # TODO: there may still be some instability in the exponent calculation. z_inv = (zfar - fragments.zbuf) / (zfar - znear) * mask + # pyre-fixme[16]: `Tuple` has no attribute `values`. + # pyre-fixme[6]: Expected `Tensor` for 1st param but got `float`. z_inv_max = torch.max(z_inv, dim=-1).values[..., None] + # pyre-fixme[6]: Expected `Tensor` for 1st param but got `float`. weights_num = prob_map * torch.exp((z_inv - z_inv_max) / blend_params.gamma) # Normalize weights. diff --git a/pytorch3d/renderer/compositing.py b/pytorch3d/renderer/compositing.py index a1e0b1ba..bc372cbd 100644 --- a/pytorch3d/renderer/compositing.py +++ b/pytorch3d/renderer/compositing.py @@ -95,6 +95,7 @@ def alpha_composite(pointsidx, alphas, pt_clds, blend_params=None) -> torch.Tens Combined features: Tensor of shape (N, C, image_size, image_size) giving the accumulated features at each point. """ + # pyre-fixme[16]: `_CompositeAlphaPoints` has no attribute `apply`. return _CompositeAlphaPoints.apply(pt_clds, alphas, pointsidx) @@ -173,6 +174,7 @@ def norm_weighted_sum(pointsidx, alphas, pt_clds, blend_params=None) -> torch.Te Combined features: Tensor of shape (N, C, image_size, image_size) giving the accumulated features at each point. """ + # pyre-fixme[16]: `_CompositeNormWeightedSumPoints` has no attribute `apply`. return _CompositeNormWeightedSumPoints.apply(pt_clds, alphas, pointsidx) @@ -244,4 +246,5 @@ def weighted_sum(pointsidx, alphas, pt_clds, blend_params=None) -> torch.Tensor: Combined features: Tensor of shape (N, C, image_size, image_size) giving the accumulated features at each point. """ + # pyre-fixme[16]: `_CompositeWeightedSumPoints` has no attribute `apply`. return _CompositeWeightedSumPoints.apply(pt_clds, alphas, pointsidx) diff --git a/pytorch3d/renderer/lighting.py b/pytorch3d/renderer/lighting.py index 2451cf95..49285cc4 100644 --- a/pytorch3d/renderer/lighting.py +++ b/pytorch3d/renderer/lighting.py @@ -183,6 +183,7 @@ class DirectionalLights(TensorProperties): direction=direction, ) _validate_light_properties(self) + # pyre-fixme[16]: `DirectionalLights` has no attribute `direction`. if self.direction.shape[-1] != 3: msg = "Expected direction to have shape (N, 3); got %r" raise ValueError(msg % repr(self.direction.shape)) @@ -196,14 +197,20 @@ class DirectionalLights(TensorProperties): # the same for directional and point lights. The call sites should not # need to know the light type. return diffuse( - normals=normals, color=self.diffuse_color, direction=self.direction + normals=normals, + # pyre-fixme[16]: `DirectionalLights` has no attribute `diffuse_color`. + color=self.diffuse_color, + # pyre-fixme[16]: `DirectionalLights` has no attribute `direction`. + direction=self.direction, ) def specular(self, normals, points, camera_position, shininess) -> torch.Tensor: return specular( points=points, normals=normals, + # pyre-fixme[16]: `DirectionalLights` has no attribute `specular_color`. color=self.specular_color, + # pyre-fixme[16]: `DirectionalLights` has no attribute `direction`. direction=self.direction, camera_position=camera_position, shininess=shininess, @@ -242,6 +249,7 @@ class PointLights(TensorProperties): location=location, ) _validate_light_properties(self) + # pyre-fixme[16]: `PointLights` has no attribute `location`. if self.location.shape[-1] != 3: msg = "Expected location to have shape (N, 3); got %r" raise ValueError(msg % repr(self.location.shape)) @@ -251,14 +259,18 @@ class PointLights(TensorProperties): return super().clone(other) def diffuse(self, normals, points) -> torch.Tensor: + # pyre-fixme[16]: `PointLights` has no attribute `location`. direction = self.location - points + # pyre-fixme[16]: `PointLights` has no attribute `diffuse_color`. return diffuse(normals=normals, color=self.diffuse_color, direction=direction) def specular(self, normals, points, camera_position, shininess) -> torch.Tensor: + # pyre-fixme[16]: `PointLights` has no attribute `location`. direction = self.location - points return specular( points=points, normals=normals, + # pyre-fixme[16]: `PointLights` has no attribute `specular_color`. color=self.specular_color, direction=direction, camera_position=camera_position, diff --git a/pytorch3d/renderer/mesh/rasterize_meshes.py b/pytorch3d/renderer/mesh/rasterize_meshes.py index 3846d4af..c190d155 100644 --- a/pytorch3d/renderer/mesh/rasterize_meshes.py +++ b/pytorch3d/renderer/mesh/rasterize_meshes.py @@ -132,6 +132,7 @@ def rasterize_meshes( if max_faces_per_bin is None: max_faces_per_bin = int(max(10000, verts_packed.shape[0] / 5)) + # pyre-fixme[16]: `_RasterizeFaceVerts` has no attribute `apply`. return _RasterizeFaceVerts.apply( face_verts, mesh_to_face_first_idx, @@ -184,6 +185,7 @@ class _RasterizeFaceVerts(torch.autograd.Function): perspective_correct: bool = False, cull_backfaces: bool = False, ): + # pyre-fixme[16]: Module `pytorch3d` has no attribute `_C`. pix_to_face, zbuf, barycentric_coords, dists = _C.rasterize_meshes( face_verts, mesh_to_face_first_idx, @@ -283,6 +285,7 @@ def rasterize_meshes_python( ) # Calculate all face bounding boxes. + # pyre-fixme[16]: `Tuple` has no attribute `values`. x_mins = torch.min(faces_verts[:, :, 0], dim=1, keepdim=True).values x_maxs = torch.max(faces_verts[:, :, 0], dim=1, keepdim=True).values y_mins = torch.min(faces_verts[:, :, 1], dim=1, keepdim=True).values diff --git a/pytorch3d/renderer/mesh/utils.py b/pytorch3d/renderer/mesh/utils.py index 3fc41f67..d065d2eb 100644 --- a/pytorch3d/renderer/mesh/utils.py +++ b/pytorch3d/renderer/mesh/utils.py @@ -63,6 +63,7 @@ def interpolate_face_attributes( pix_to_face = pix_to_face.clone() pix_to_face[mask] = 0 idx = pix_to_face.view(N * H * W * K, 1, 1).expand(N * H * W * K, 3, D) + # pyre-fixme[16]: `Tensor` has no attribute `gather`. pixel_face_vals = face_attributes.gather(0, idx).view(N, H, W, K, 3, D) pixel_vals = (barycentric_coords[..., None] * pixel_face_vals).sum(dim=-2) pixel_vals[mask] = 0 # Replace masked values in output. diff --git a/pytorch3d/renderer/points/rasterize_points.py b/pytorch3d/renderer/points/rasterize_points.py index 69d97257..345ea8e9 100644 --- a/pytorch3d/renderer/points/rasterize_points.py +++ b/pytorch3d/renderer/points/rasterize_points.py @@ -89,6 +89,7 @@ def rasterize_points( if bin_size != 0: # There is a limit on the number of points per bin in the cuda kernel. + # pyre-fixme[6]: Expected `int` for 1st param but got `Union[int, None, int]`. points_per_bin = 1 + (image_size - 1) // bin_size if points_per_bin >= kMaxPointsPerBin: raise ValueError( @@ -101,6 +102,7 @@ def rasterize_points( # Function.apply cannot take keyword args, so we handle defaults in this # wrapper and call apply with positional args only + # pyre-fixme[16]: `_RasterizePoints` has no attribute `apply`. return _RasterizePoints.apply( points_packed, cloud_to_packed_first_idx, @@ -138,6 +140,7 @@ class _RasterizePoints(torch.autograd.Function): bin_size, max_points_per_bin, ) + # pyre-fixme[16]: Module `pytorch3d` has no attribute `_C`. idx, zbuf, dists = _C.rasterize_points(*args) ctx.save_for_backward(points, idx) ctx.mark_non_differentiable(idx) diff --git a/pytorch3d/structures/meshes.py b/pytorch3d/structures/meshes.py index a4431ce3..09fa5c1f 100644 --- a/pytorch3d/structures/meshes.py +++ b/pytorch3d/structures/meshes.py @@ -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: diff --git a/pytorch3d/structures/textures.py b/pytorch3d/structures/textures.py index 803167ba..25129108 100644 --- a/pytorch3d/structures/textures.py +++ b/pytorch3d/structures/textures.py @@ -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: diff --git a/pytorch3d/structures/utils.py b/pytorch3d/structures/utils.py index c4682b02..b71f8394 100644 --- a/pytorch3d/structures/utils.py +++ b/pytorch3d/structures/utils.py @@ -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, diff --git a/pytorch3d/transforms/so3.py b/pytorch3d/transforms/so3.py index 57ef51b0..9345a678 100644 --- a/pytorch3d/transforms/so3.py +++ b/pytorch3d/transforms/so3.py @@ -77,6 +77,7 @@ def so3_rotation_angle(R, eps: float = 1e-4, cos_angle: bool = False): if cos_angle: return phi else: + # pyre-fixme[16]: `float` has no attribute `acos`. return phi.acos() @@ -118,6 +119,7 @@ def so3_exponential_map(log_rot, eps: float = 0.0001): skews = hat(log_rot) R = ( + # pyre-fixme[16]: `float` has no attribute `__getitem__`. fac1[:, None, None] * skews + fac2[:, None, None] * torch.bmm(skews, skews) + torch.eye(3, dtype=log_rot.dtype, device=log_rot.device)[None] diff --git a/pytorch3d/transforms/transform3d.py b/pytorch3d/transforms/transform3d.py index a5fdeeff..455edfeb 100644 --- a/pytorch3d/transforms/transform3d.py +++ b/pytorch3d/transforms/transform3d.py @@ -155,6 +155,7 @@ 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: