From 51fd114d8b8eed19226870ee7fd12dba1e25d550 Mon Sep 17 00:00:00 2001 From: Huy Do Date: Thu, 27 Jun 2024 07:35:18 -0700 Subject: [PATCH] Forward fix internal pyre failure from D58983461 Summary: X-link: https://github.com/pytorch/pytorch/pull/129525 Somehow, using underscore alias of some builtin types breaks pyre Reviewed By: malfet, clee2000 Differential Revision: D59029768 fbshipit-source-id: cfa2171b66475727b9545355e57a8297c1dc0bc6 --- pytorch3d/implicitron/models/utils.py | 1 - pytorch3d/ops/utils.py | 2 -- pytorch3d/renderer/blending.py | 6 +++--- pytorch3d/renderer/cameras.py | 2 -- pytorch3d/renderer/utils.py | 2 ++ 5 files changed, 5 insertions(+), 8 deletions(-) diff --git a/pytorch3d/implicitron/models/utils.py b/pytorch3d/implicitron/models/utils.py index 6132e9ad..70b2fc06 100644 --- a/pytorch3d/implicitron/models/utils.py +++ b/pytorch3d/implicitron/models/utils.py @@ -121,7 +121,6 @@ def weighted_sum_losses( return None loss = sum(losses_weighted) assert torch.is_tensor(loss) - # pyre-fixme[7]: Expected `Optional[Tensor]` but got `int`. return loss diff --git a/pytorch3d/ops/utils.py b/pytorch3d/ops/utils.py index d2f68294..29afc3f9 100644 --- a/pytorch3d/ops/utils.py +++ b/pytorch3d/ops/utils.py @@ -143,8 +143,6 @@ def convert_pointclouds_to_tensor(pcl: Union[torch.Tensor, "Pointclouds"]): elif torch.is_tensor(pcl): X = pcl num_points = X.shape[1] * torch.ones( # type: ignore - # pyre-fixme[16]: Item `Pointclouds` of `Union[Pointclouds, Tensor]` has - # no attribute `shape`. X.shape[0], device=X.device, dtype=torch.int64, diff --git a/pytorch3d/renderer/blending.py b/pytorch3d/renderer/blending.py index 5673c54b..b84b91ab 100644 --- a/pytorch3d/renderer/blending.py +++ b/pytorch3d/renderer/blending.py @@ -212,15 +212,15 @@ def softmax_rgb_blend( # Reshape to be compatible with (N, H, W, K) values in fragments if torch.is_tensor(zfar): - # pyre-fixme[16] zfar = zfar[:, None, None, None] if torch.is_tensor(znear): - # pyre-fixme[16]: Item `float` of `Union[float, Tensor]` has no attribute - # `__getitem__`. znear = znear[:, None, None, None] + # pyre-fixme[6]: Expected `float` but got `Union[float, Tensor]` z_inv = (zfar - fragments.zbuf) / (zfar - znear) * mask + # pyre-fixme[6]: Expected `Tensor` but got `float` z_inv_max = torch.max(z_inv, dim=-1).values[..., None].clamp(min=eps) + # pyre-fixme[6]: Expected `Tensor` but got `float` weights_num = prob_map * torch.exp((z_inv - z_inv_max) / blend_params.gamma) # Also apply exp normalize trick for the background color weight. diff --git a/pytorch3d/renderer/cameras.py b/pytorch3d/renderer/cameras.py index d3d4ff24..7ac72033 100644 --- a/pytorch3d/renderer/cameras.py +++ b/pytorch3d/renderer/cameras.py @@ -1782,8 +1782,6 @@ def get_ndc_to_screen_transform( K = torch.zeros((cameras._N, 4, 4), device=cameras.device, dtype=torch.float32) if not torch.is_tensor(image_size): image_size = torch.tensor(image_size, device=cameras.device) - # pyre-fixme[16]: Item `List` of `Union[List[typing.Any], Tensor, Tuple[Any, - # ...]]` has no attribute `view`. image_size = image_size.view(-1, 2) # of shape (1 or B)x2 height, width = image_size.unbind(1) diff --git a/pytorch3d/renderer/utils.py b/pytorch3d/renderer/utils.py index e389b4d8..ac7e8c85 100644 --- a/pytorch3d/renderer/utils.py +++ b/pytorch3d/renderer/utils.py @@ -270,6 +270,8 @@ class TensorProperties(nn.Module): # to have the same shape as the input tensor. new_dims = len(tensor_dims) - len(idx_dims) new_shape = idx_dims + (1,) * new_dims + # pyre-fixme[58]: `+` is not supported for operand types + # `Tuple[int]` and `torch._C.Size` expand_dims = (-1,) + tensor_dims[1:] _batch_idx = _batch_idx.view(*new_shape) _batch_idx = _batch_idx.expand(*expand_dims)