Skip to content

Commit

Permalink
Avoid creating a tensor of shape when not tracing
Browse files Browse the repository at this point in the history
This is a small follow up on #7592
that makes this Dynamo exportable.

Signed-off-by: Edward Z. Yang <ezyang@meta.com>
  • Loading branch information
ezyang committed Sep 7, 2023
1 parent e13b8f5 commit d50177f
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion torchvision/models/detection/transform.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,10 @@ def _resize_image_and_masks(
) -> Tuple[Tensor, Optional[Dict[str, Tensor]]]:
if torchvision._is_tracing():
im_shape = _get_shape_onnx(image)
else:
elif torch.jit.is_scripting():
im_shape = torch.tensor(image.shape[-2:])
else:
im_shape = image.shape[-2:]

size: Optional[List[int]] = None
scale_factor: Optional[float] = None
Expand Down

0 comments on commit d50177f

Please sign in to comment.