Skip to content

Commit ae68a54

Browse files
generatedunixname89002005307016facebook-github-bot
generatedunixname89002005307016
authored andcommitted
suppress errors in vision - batch 1
Summary: This diff is auto-generated to upgrade the Pyre version and suppress errors in vision. The upgrade will affect Pyre local configurations in the following directories: ``` vision/ale/search vision/fair/fvcore vision/fair/pytorch3d vision/ocr/rosetta_hash vision/vogue/personalization ``` Differential Revision: D21688454 fbshipit-source-id: 1f3c3fee42b6da2e162fd0932742ab8c5c96aa45
1 parent d689baa commit ae68a54

22 files changed

+103
-5
lines changed

pytorch3d/io/mtl_io.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ def make_mesh_texture_atlas(
5151

5252
# Initialize the per face texture map to a white color.
5353
# TODO: allow customization of this base color?
54+
# pyre-fixme[16]: `Tensor` has no attribute `new_ones`.
5455
atlas = faces_verts_uvs.new_ones(size=(F, R, R, 3))
5556

5657
# Check for empty materials.
@@ -63,10 +64,13 @@ def make_mesh_texture_atlas(
6364
# will be ignored and a repeating pattern is formed.
6465
# Shapenet data uses this format see:
6566
# 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
67+
# pyre-fixme[16]: `ByteTensor` has no attribute `any`.
6668
if (faces_verts_uvs > 1).any() or (faces_verts_uvs < 0).any():
6769
msg = "Texture UV coordinates outside the range [0, 1]. \
6870
The integer part will be ignored to form a repeating pattern."
6971
warnings.warn(msg)
72+
# pyre-fixme[9]: faces_verts_uvs has type `Tensor`; used as `int`.
73+
# pyre-fixme[6]: Expected `int` for 1st param but got `Tensor`.
7074
faces_verts_uvs = faces_verts_uvs % 1
7175
elif texture_wrap == "clamp":
7276
# Clamp uv coordinates to the [0, 1] range.
@@ -257,6 +261,7 @@ def make_material_atlas(
257261
# Meshgrid returns (row, column) i.e (Y, X)
258262
# Change order to (X, Y) to make the grid.
259263
Y, X = torch.meshgrid(rng, rng)
264+
# pyre-fixme[28]: Unexpected keyword argument `axis`.
260265
grid = torch.stack([X, Y], axis=-1) # (R, R, 2)
261266

262267
# Grid cells below the diagonal: x + y < R.
@@ -269,6 +274,7 @@ def make_material_atlas(
269274
# w0, w1
270275
bary[below_diag, slc] = ((grid[below_diag] + 1.0 / 3.0) / R).T
271276
# w0, w1 for above diagonal grid cells.
277+
# pyre-fixme[16]: `float` has no attribute `T`.
272278
bary[~below_diag, slc] = (((R - 1.0 - grid[~below_diag]) + 2.0 / 3.0) / R).T
273279
# w2 = 1. - w0 - w1
274280
bary[..., -1] = 1 - bary[..., :2].sum(dim=-1)

pytorch3d/io/obj_io.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,8 @@ def load_obj(
213213
"""
214214
data_dir = "./"
215215
if isinstance(f_obj, (str, bytes, os.PathLike)):
216+
# pyre-fixme[6]: Expected `_PathLike[Variable[typing.AnyStr <: [str,
217+
# bytes]]]` for 1st param but got `Union[_PathLike[typing.Any], bytes, str]`.
216218
data_dir = os.path.dirname(f_obj)
217219
f_obj, new_f = _open_file(f_obj)
218220
try:
@@ -453,6 +455,8 @@ def _load(
453455
material_colors, texture_images, texture_atlas = None, None, None
454456
if load_textures:
455457
if (len(material_names) > 0) and (f_mtl is not None):
458+
# pyre-fixme[6]: Expected `Union[_PathLike[typing.Any], bytes, str]` for
459+
# 1st param but got `Optional[str]`.
456460
if os.path.isfile(f_mtl):
457461
# Texture mode uv wrap
458462
material_colors, texture_images = load_mtl(

pytorch3d/io/utils.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,8 @@ def _read_image(file_name: str, format=None):
3030
if format not in ["RGB", "BGR"]:
3131
raise ValueError("format can only be one of [RGB, BGR]; got %s", format)
3232
with PathManager.open(file_name, "rb") as f:
33+
# pyre-fixme[6]: Expected `Union[str, typing.BinaryIO]` for 1st param but
34+
# got `Union[typing.IO[bytes], typing.IO[str]]`.
3335
image = Image.open(f)
3436
if format is not None:
3537
# PIL only supports RGB. First convert to RGB and flip channels

pytorch3d/loss/chamfer.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ def _handle_pointcloud_input(
4141
lengths = points.num_points_per_cloud()
4242
normals = points.normals_padded() # either a tensor or None
4343
elif torch.is_tensor(points):
44+
# pyre-fixme[16]: `Tensor` has no attribute `ndim`.
4445
if points.ndim != 3:
4546
raise ValueError("Expected points to be of shape (N, P, D)")
4647
X = points
@@ -173,6 +174,7 @@ def chamfer_distance(
173174
)
174175

175176
if is_x_heterogeneous:
177+
# pyre-fixme[16]: `int` has no attribute `__setitem__`.
176178
cham_norm_x[x_mask] = 0.0
177179
if is_y_heterogeneous:
178180
cham_norm_y[y_mask] = 0.0

pytorch3d/loss/point_mesh_distance.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ def backward(ctx, grad_dists):
6565
return grad_points, None, grad_tris, None, None
6666

6767

68+
# pyre-fixme[16]: `_PointFaceDistance` has no attribute `apply`.
6869
point_face_distance = _PointFaceDistance.apply
6970

7071

@@ -115,6 +116,7 @@ def backward(ctx, grad_dists):
115116
return grad_points, None, grad_tris, None, None
116117

117118

119+
# pyre-fixme[16]: `_FacePointDistance` has no attribute `apply`.
118120
face_point_distance = _FacePointDistance.apply
119121

120122

@@ -165,6 +167,7 @@ def backward(ctx, grad_dists):
165167
return grad_points, None, grad_segms, None, None
166168

167169

170+
# pyre-fixme[16]: `_PointEdgeDistance` has no attribute `apply`.
168171
point_edge_distance = _PointEdgeDistance.apply
169172

170173

@@ -215,6 +218,7 @@ def backward(ctx, grad_dists):
215218
return grad_points, None, grad_segms, None, None
216219

217220

221+
# pyre-fixme[16]: `_EdgePointDistance` has no attribute `apply`.
218222
edge_point_distance = _EdgePointDistance.apply
219223

220224

pytorch3d/ops/cubify.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -229,6 +229,7 @@ def cubify(voxels, thresh, device=None, align: str = "topleft") -> Meshes:
229229
idlenum = idleverts.cumsum(1)
230230

231231
verts_list = [
232+
# pyre-fixme[16]: `Tensor` has no attribute `index_select`.
232233
grid_verts.index_select(0, (idleverts[n] == 0).nonzero(as_tuple=False)[:, 0])
233234
for n in range(N)
234235
]

pytorch3d/ops/graph_conv.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ def __init__(
3535
if init == "normal":
3636
nn.init.normal_(self.w0.weight, mean=0, std=0.01)
3737
nn.init.normal_(self.w1.weight, mean=0, std=0.01)
38+
# pyre-fixme[16]: Optional type has no attribute `data`.
3839
self.w0.bias.data.zero_()
3940
self.w1.bias.data.zero_()
4041
elif init == "zero":
@@ -115,6 +116,7 @@ def gather_scatter_python(input, edges, directed: bool = False):
115116
idx0 = edges[:, 0].view(num_edges, 1).expand(num_edges, input_feature_dim)
116117
idx1 = edges[:, 1].view(num_edges, 1).expand(num_edges, input_feature_dim)
117118

119+
# pyre-fixme[16]: `Tensor` has no attribute `scatter_add`.
118120
output = output.scatter_add(0, idx0, input.gather(0, idx1))
119121
if not directed:
120122
output = output.scatter_add(0, idx1, input.gather(0, idx0))
@@ -167,4 +169,5 @@ def backward(ctx, grad_output):
167169
return grad_input, grad_edges, grad_directed
168170

169171

172+
# pyre-fixme[16]: `GatherScatter` has no attribute `apply`.
170173
gather_scatter = GatherScatter.apply

pytorch3d/ops/knn.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -157,6 +157,7 @@ def knn_points(
157157
if lengths2 is None:
158158
lengths2 = torch.full((p1.shape[0],), P2, dtype=torch.int64, device=p1.device)
159159

160+
# pyre-fixme[16]: `_knn_points` has no attribute `apply`.
160161
p1_dists, p1_idx = _knn_points.apply(p1, p2, lengths1, lengths2, K, version)
161162

162163
p2_nn = None

pytorch3d/ops/mesh_face_areas_normals.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,4 +59,5 @@ def backward(ctx, grad_areas, grad_normals):
5959
return grad_verts, None
6060

6161

62+
# pyre-fixme[16]: `_MeshFaceAreasNormals` has no attribute `apply`.
6263
mesh_face_areas_normals = _MeshFaceAreasNormals.apply

pytorch3d/ops/sample_points_from_meshes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,4 +120,6 @@ def _rand_barycentric_coords(
120120
w0 = 1.0 - u_sqrt
121121
w1 = u_sqrt * (1.0 - v)
122122
w2 = u_sqrt * v
123+
# pyre-fixme[7]: Expected `Tuple[torch.Tensor, torch.Tensor, torch.Tensor]` but
124+
# got `Tuple[float, typing.Any, typing.Any]`.
123125
return w0, w1, w2

pytorch3d/ops/vert_align.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ def vert_align(
9696
.view(-1, 1)
9797
.expand(-1, feats_sampled.shape[-1])
9898
)
99+
# pyre-fixme[16]: `Tensor` has no attribute `gather`.
99100
feats_sampled = feats_sampled.gather(0, idx) # (sum(V), C)
100101

101102
return feats_sampled

pytorch3d/renderer/blending.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,10 @@ def softmax_rgb_blend(
150150
# TODO: there may still be some instability in the exponent calculation.
151151

152152
z_inv = (zfar - fragments.zbuf) / (zfar - znear) * mask
153+
# pyre-fixme[16]: `Tuple` has no attribute `values`.
154+
# pyre-fixme[6]: Expected `Tensor` for 1st param but got `float`.
153155
z_inv_max = torch.max(z_inv, dim=-1).values[..., None]
156+
# pyre-fixme[6]: Expected `Tensor` for 1st param but got `float`.
154157
weights_num = prob_map * torch.exp((z_inv - z_inv_max) / blend_params.gamma)
155158

156159
# Normalize weights.

pytorch3d/renderer/compositing.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ def alpha_composite(pointsidx, alphas, pt_clds, blend_params=None) -> torch.Tens
9595
Combined features: Tensor of shape (N, C, image_size, image_size)
9696
giving the accumulated features at each point.
9797
"""
98+
# pyre-fixme[16]: `_CompositeAlphaPoints` has no attribute `apply`.
9899
return _CompositeAlphaPoints.apply(pt_clds, alphas, pointsidx)
99100

100101

@@ -173,6 +174,7 @@ def norm_weighted_sum(pointsidx, alphas, pt_clds, blend_params=None) -> torch.Te
173174
Combined features: Tensor of shape (N, C, image_size, image_size)
174175
giving the accumulated features at each point.
175176
"""
177+
# pyre-fixme[16]: `_CompositeNormWeightedSumPoints` has no attribute `apply`.
176178
return _CompositeNormWeightedSumPoints.apply(pt_clds, alphas, pointsidx)
177179

178180

@@ -244,4 +246,5 @@ def weighted_sum(pointsidx, alphas, pt_clds, blend_params=None) -> torch.Tensor:
244246
Combined features: Tensor of shape (N, C, image_size, image_size)
245247
giving the accumulated features at each point.
246248
"""
249+
# pyre-fixme[16]: `_CompositeWeightedSumPoints` has no attribute `apply`.
247250
return _CompositeWeightedSumPoints.apply(pt_clds, alphas, pointsidx)

pytorch3d/renderer/lighting.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -183,6 +183,7 @@ def __init__(
183183
direction=direction,
184184
)
185185
_validate_light_properties(self)
186+
# pyre-fixme[16]: `DirectionalLights` has no attribute `direction`.
186187
if self.direction.shape[-1] != 3:
187188
msg = "Expected direction to have shape (N, 3); got %r"
188189
raise ValueError(msg % repr(self.direction.shape))
@@ -196,14 +197,20 @@ def diffuse(self, normals, points=None) -> torch.Tensor:
196197
# the same for directional and point lights. The call sites should not
197198
# need to know the light type.
198199
return diffuse(
199-
normals=normals, color=self.diffuse_color, direction=self.direction
200+
normals=normals,
201+
# pyre-fixme[16]: `DirectionalLights` has no attribute `diffuse_color`.
202+
color=self.diffuse_color,
203+
# pyre-fixme[16]: `DirectionalLights` has no attribute `direction`.
204+
direction=self.direction,
200205
)
201206

202207
def specular(self, normals, points, camera_position, shininess) -> torch.Tensor:
203208
return specular(
204209
points=points,
205210
normals=normals,
211+
# pyre-fixme[16]: `DirectionalLights` has no attribute `specular_color`.
206212
color=self.specular_color,
213+
# pyre-fixme[16]: `DirectionalLights` has no attribute `direction`.
207214
direction=self.direction,
208215
camera_position=camera_position,
209216
shininess=shininess,
@@ -242,6 +249,7 @@ def __init__(
242249
location=location,
243250
)
244251
_validate_light_properties(self)
252+
# pyre-fixme[16]: `PointLights` has no attribute `location`.
245253
if self.location.shape[-1] != 3:
246254
msg = "Expected location to have shape (N, 3); got %r"
247255
raise ValueError(msg % repr(self.location.shape))
@@ -251,14 +259,18 @@ def clone(self):
251259
return super().clone(other)
252260

253261
def diffuse(self, normals, points) -> torch.Tensor:
262+
# pyre-fixme[16]: `PointLights` has no attribute `location`.
254263
direction = self.location - points
264+
# pyre-fixme[16]: `PointLights` has no attribute `diffuse_color`.
255265
return diffuse(normals=normals, color=self.diffuse_color, direction=direction)
256266

257267
def specular(self, normals, points, camera_position, shininess) -> torch.Tensor:
268+
# pyre-fixme[16]: `PointLights` has no attribute `location`.
258269
direction = self.location - points
259270
return specular(
260271
points=points,
261272
normals=normals,
273+
# pyre-fixme[16]: `PointLights` has no attribute `specular_color`.
262274
color=self.specular_color,
263275
direction=direction,
264276
camera_position=camera_position,

pytorch3d/renderer/mesh/rasterize_meshes.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ def rasterize_meshes(
132132
if max_faces_per_bin is None:
133133
max_faces_per_bin = int(max(10000, verts_packed.shape[0] / 5))
134134

135+
# pyre-fixme[16]: `_RasterizeFaceVerts` has no attribute `apply`.
135136
return _RasterizeFaceVerts.apply(
136137
face_verts,
137138
mesh_to_face_first_idx,
@@ -184,6 +185,7 @@ def forward(
184185
perspective_correct: bool = False,
185186
cull_backfaces: bool = False,
186187
):
188+
# pyre-fixme[16]: Module `pytorch3d` has no attribute `_C`.
187189
pix_to_face, zbuf, barycentric_coords, dists = _C.rasterize_meshes(
188190
face_verts,
189191
mesh_to_face_first_idx,
@@ -283,6 +285,7 @@ def rasterize_meshes_python(
283285
)
284286

285287
# Calculate all face bounding boxes.
288+
# pyre-fixme[16]: `Tuple` has no attribute `values`.
286289
x_mins = torch.min(faces_verts[:, :, 0], dim=1, keepdim=True).values
287290
x_maxs = torch.max(faces_verts[:, :, 0], dim=1, keepdim=True).values
288291
y_mins = torch.min(faces_verts[:, :, 1], dim=1, keepdim=True).values

pytorch3d/renderer/mesh/utils.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,7 @@ def interpolate_face_attributes(
6363
pix_to_face = pix_to_face.clone()
6464
pix_to_face[mask] = 0
6565
idx = pix_to_face.view(N * H * W * K, 1, 1).expand(N * H * W * K, 3, D)
66+
# pyre-fixme[16]: `Tensor` has no attribute `gather`.
6667
pixel_face_vals = face_attributes.gather(0, idx).view(N, H, W, K, 3, D)
6768
pixel_vals = (barycentric_coords[..., None] * pixel_face_vals).sum(dim=-2)
6869
pixel_vals[mask] = 0 # Replace masked values in output.

pytorch3d/renderer/points/rasterize_points.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,7 @@ def rasterize_points(
8989

9090
if bin_size != 0:
9191
# There is a limit on the number of points per bin in the cuda kernel.
92+
# pyre-fixme[6]: Expected `int` for 1st param but got `Union[int, None, int]`.
9293
points_per_bin = 1 + (image_size - 1) // bin_size
9394
if points_per_bin >= kMaxPointsPerBin:
9495
raise ValueError(
@@ -101,6 +102,7 @@ def rasterize_points(
101102

102103
# Function.apply cannot take keyword args, so we handle defaults in this
103104
# wrapper and call apply with positional args only
105+
# pyre-fixme[16]: `_RasterizePoints` has no attribute `apply`.
104106
return _RasterizePoints.apply(
105107
points_packed,
106108
cloud_to_packed_first_idx,
@@ -138,6 +140,7 @@ def forward(
138140
bin_size,
139141
max_points_per_bin,
140142
)
143+
# pyre-fixme[16]: Module `pytorch3d` has no attribute `_C`.
141144
idx, zbuf, dists = _C.rasterize_points(*args)
142145
ctx.save_for_backward(points, idx)
143146
ctx.mark_non_differentiable(idx)

pytorch3d/structures/meshes.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -820,6 +820,7 @@ def _compute_vertex_normals(self, refresh: bool = False):
820820

821821
# NOTE: this is already applying the area weighting as the magnitude
822822
# of the cross product is 2 x area of the triangle.
823+
# pyre-fixme[16]: `Tensor` has no attribute `index_add`.
823824
verts_normals = verts_normals.index_add(
824825
0,
825826
faces_packed[:, 1],
@@ -1392,6 +1393,7 @@ def join_meshes_as_batch(meshes: List[Meshes], include_textures: bool = True):
13921393
# Meshes objects can be iterated and produce single Meshes. We avoid
13931394
# letting join_meshes_as_batch(mesh1, mesh2) silently do the wrong thing.
13941395
raise ValueError("Wrong first argument to join_meshes_as_batch.")
1396+
# pyre-fixme[10]: Name `mesh` is used but not defined.
13951397
verts = [v for mesh in meshes for v in mesh.verts_list()]
13961398
faces = [f for mesh in meshes for f in mesh.faces_list()]
13971399
if len(meshes) == 0 or not include_textures:

0 commit comments

Comments
 (0)