From 1f9cf91e1b59c1b140efaf9f384e6248c4a125d8 Mon Sep 17 00:00:00 2001 From: generatedunixname89002005307016 Date: Tue, 5 Jan 2021 05:27:11 -0800 Subject: [PATCH] suppress errors in `vision/fair/pytorch3d` Differential Revision: D25781183 fbshipit-source-id: e27808a4c2b94bba205756001cb909827182b592 --- pytorch3d/ops/points_to_volumes.py | 13 +++++++++++++ pytorch3d/renderer/implicit/raymarching.py | 3 +++ pytorch3d/structures/volumes.py | 7 +++++++ 3 files changed, 23 insertions(+) diff --git a/pytorch3d/ops/points_to_volumes.py b/pytorch3d/ops/points_to_volumes.py index dd3df490..29e0ed88 100644 --- a/pytorch3d/ops/points_to_volumes.py +++ b/pytorch3d/ops/points_to_volumes.py @@ -184,6 +184,7 @@ def add_points_features_to_volume_densities_features( if volume_features is None: # initialize features if not passed in + # pyre-fixme[16]: `Tensor` has no attribute `new_zeros`. volume_features_flatten = volume_densities.new_zeros(ba, feature_dim, n_voxels) else: # otherwise just flatten @@ -227,6 +228,7 @@ def _check_points_to_volumes_inputs( mask: Optional[torch.Tensor] = None, ): + # pyre-fixme[16]: `Tuple` has no attribute `values`. max_grid_size = grid_sizes.max(dim=0).values if torch.prod(max_grid_size) > volume_densities.shape[1]: raise ValueError( @@ -321,9 +323,11 @@ def splat_points_to_volumes( rXYZ = points_3d_indices - XYZ.type_as(points_3d) # remainder of floor # split into separate coordinate vectors + # pyre-fixme[16]: `LongTensor` has no attribute `split`. X, Y, Z = XYZ.split(1, dim=2) # rX = remainder after floor = 1-"the weight of each vote into # the X coordinate of the 8-neighborhood" + # pyre-fixme[16]: `Tensor` has no attribute `split`. rX, rY, rZ = rXYZ.split(1, dim=2) # get random indices for the purpose of adding out-of-bounds values @@ -344,6 +348,7 @@ def splat_points_to_volumes( w = wX * wY * wZ # valid - binary indicators of votes that fall into the volume + # pyre-fixme[16]: `int` has no attribute `long`. valid = ( (0 <= X_) * (X_ < grid_sizes_xyz[:, None, 0:1]) @@ -362,20 +367,25 @@ def splat_points_to_volumes( idx_valid = idx * valid + rand_idx * (1 - valid) w_valid = w * valid.type_as(w) if mask is not None: + # pyre-fixme[6]: Expected `_OtherTensor` for 1st param but got + # `int`. w_valid = w_valid * mask.type_as(w)[:, :, None] # scatter add casts the votes into the weight accumulator # and the feature accumulator + # pyre-fixme[16]: `Tensor` has no attribute `scatter_add_`. volume_densities.scatter_add_(1, idx_valid, w_valid) # reshape idx_valid -> (minibatch, feature_dim, n_points) idx_valid = idx_valid.view(ba, 1, n_points).expand_as(points_features) + # pyre-fixme[16]: `int` has no attribute `view`. w_valid = w_valid.view(ba, 1, n_points) # volume_features of shape (minibatch, feature_dim, n_voxels) volume_features.scatter_add_(2, idx_valid, w_valid * points_features) # divide each feature by the total weight of the votes + # pyre-fixme[20]: Argument `max` expected. volume_features = volume_features / volume_densities.view(ba, 1, n_voxels).clamp( min_weight ) @@ -453,6 +463,7 @@ def round_points_to_volumes( # valid - binary indicators of votes that fall into the volume grid_sizes = grid_sizes.type_as(XYZ) + # pyre-fixme[16]: `int` has no attribute `long`. valid = ( (0 <= X) * (X < grid_sizes_xyz[:, None, 0:1]) @@ -474,6 +485,7 @@ def round_points_to_volumes( # scatter add casts the votes into the weight accumulator # and the feature accumulator + # pyre-fixme[16]: `Tensor` has no attribute `scatter_add_`. volume_densities.scatter_add_(1, idx_valid, w_valid) # reshape idx_valid -> (minibatch, feature_dim, n_points) @@ -484,6 +496,7 @@ def round_points_to_volumes( volume_features.scatter_add_(2, idx_valid, w_valid * points_features) # divide each feature by the total weight of the votes + # pyre-fixme[20]: Argument `max` expected. volume_features = volume_features / volume_densities.view(ba, 1, n_voxels).clamp( 1.0 ) diff --git a/pytorch3d/renderer/implicit/raymarching.py b/pytorch3d/renderer/implicit/raymarching.py index 44308226..b5164dab 100644 --- a/pytorch3d/renderer/implicit/raymarching.py +++ b/pytorch3d/renderer/implicit/raymarching.py @@ -153,6 +153,7 @@ class AbsorptionOnlyRaymarcher(torch.nn.Module): _check_density_bounds(rays_densities) total_transmission = torch.prod(1 - rays_densities, dim=-1, keepdim=True) opacities = 1.0 - total_transmission + # pyre-fixme[7]: Expected `Optional[torch.Tensor]` but got `float`. return opacities @@ -176,6 +177,7 @@ def _check_density_bounds( Checks whether the elements of `rays_densities` range within `bounds`. If not issues a warning. """ + # pyre-fixme[16]: `ByteTensor` has no attribute `any`. if ((rays_densities > bounds[1]) | (rays_densities < bounds[0])).any(): warnings.warn( "One or more elements of rays_densities are outside of valid" @@ -213,6 +215,7 @@ def _check_raymarcher_inputs( rays_shape = rays_densities.shape[:-1] + # pyre-fixme[16]: `Optional` has no attribute `shape`. if not z_can_be_none and rays_z.shape != rays_shape: raise ValueError("rays_z have to be of the same shape as rays_densities.") diff --git a/pytorch3d/structures/volumes.py b/pytorch3d/structures/volumes.py index 83597395..928c9fac 100644 --- a/pytorch3d/structures/volumes.py +++ b/pytorch3d/structures/volumes.py @@ -473,6 +473,7 @@ class Volumes(object): ) def __len__(self) -> int: + # pyre-fixme[16]: `List` has no attribute `shape`. return self._densities.shape[0] def __getitem__( @@ -497,6 +498,7 @@ class Volumes(object): raise IndexError(index) new = self.__class__( + # pyre-fixme[16]: `Optional` has no attribute `__getitem__`. features=self.features()[index] if self._features is not None else None, densities=self.densities()[index], ) @@ -521,6 +523,8 @@ class Volumes(object): Returns: **densities**: The tensor of volume densities. """ + # pyre-fixme[7]: Expected `Tensor` but got `Union[List[torch.Tensor], + # torch.Tensor]`. return self._densities def densities_list(self) -> List[torch.Tensor]: @@ -542,6 +546,7 @@ class Volumes(object): """ if self._features is None: # No features provided so return None + # pyre-fixme[7]: Expected `List[torch.Tensor]` but got `None`. return None return self._features_densities_list(self.features()) @@ -687,8 +692,10 @@ class Volumes(object): other = self.clone() if self.device != device: other.device = device + # pyre-fixme[16]: `List` has no attribute `to`. other._densities = self._densities.to(device) if self._features is not None: + # pyre-fixme[16]: `Optional` has no attribute `to`. other._features = self.features().to(device) other._local_to_world_transform = ( self.get_local_to_world_coords_transform().to(device)