Skip to content

Commit

Permalink
Forward fix internal pyre failure from D58983461
Browse files Browse the repository at this point in the history
Summary:
X-link: pytorch/pytorch#129525

Somehow, using underscore alias of some builtin types breaks pyre

Reviewed By: malfet, clee2000

Differential Revision: D59029768

fbshipit-source-id: cfa2171b66475727b9545355e57a8297c1dc0bc6
  • Loading branch information
huydhn authored and facebook-github-bot committed Jun 27, 2024
1 parent 8965341 commit 51fd114
Show file tree
Hide file tree
Showing 5 changed files with 5 additions and 8 deletions.
1 change: 0 additions & 1 deletion pytorch3d/implicitron/models/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down
2 changes: 0 additions & 2 deletions pytorch3d/ops/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
6 changes: 3 additions & 3 deletions pytorch3d/renderer/blending.py
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 0 additions & 2 deletions pytorch3d/renderer/cameras.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
2 changes: 2 additions & 0 deletions pytorch3d/renderer/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -270,6 +270,8 @@ def gather_props(self, batch_idx) -> "TensorProperties":
# 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)
Expand Down

0 comments on commit 51fd114

Please sign in to comment.