Skip to content

Commit 5162bee

Browse files
authored
Removed JIT FC tweaks for interpolation options
1 parent eeda31f commit 5162bee

File tree

1 file changed

+8
-23
lines changed

1 file changed

+8
-23
lines changed

torch/nn/functional.py

Lines changed: 8 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3863,17 +3863,12 @@ def interpolate(input: Tensor, size: Optional[int] = None, scale_factor: Optiona
38633863
if input.dim() == 5 and mode == "nearest":
38643864
return torch._C._nn.upsample_nearest3d(input, output_size, scale_factors)
38653865

3866-
# TODO: Remove this scripting logic once the 2-week FC window has passed.
3867-
if mode == "nearest-exact":
3868-
if not torch.jit.is_scripting():
3869-
if input.dim() == 3 and mode == "nearest-exact":
3870-
return torch._C._nn._upsample_nearest_exact1d(input, output_size, scale_factors)
3871-
if input.dim() == 4 and mode == "nearest-exact":
3872-
return torch._C._nn._upsample_nearest_exact2d(input, output_size, scale_factors)
3873-
if input.dim() == 5 and mode == "nearest-exact":
3874-
return torch._C._nn._upsample_nearest_exact3d(input, output_size, scale_factors)
3875-
else:
3876-
raise RuntimeError("TorchScript currently does not support nearest-exact")
3866+
if input.dim() == 3 and mode == "nearest-exact":
3867+
return torch._C._nn._upsample_nearest_exact1d(input, output_size, scale_factors)
3868+
if input.dim() == 4 and mode == "nearest-exact":
3869+
return torch._C._nn._upsample_nearest_exact2d(input, output_size, scale_factors)
3870+
if input.dim() == 5 and mode == "nearest-exact":
3871+
return torch._C._nn._upsample_nearest_exact3d(input, output_size, scale_factors)
38773872

38783873
if input.dim() == 3 and mode == "area":
38793874
assert output_size is not None
@@ -3890,26 +3885,16 @@ def interpolate(input: Tensor, size: Optional[int] = None, scale_factor: Optiona
38903885
return torch._C._nn.upsample_linear1d(input, output_size, align_corners, scale_factors)
38913886
if input.dim() == 4 and mode == "bilinear":
38923887
assert align_corners is not None
3893-
# Enforce that the full call with the new kwarg is not invoked when scripting.
3894-
# TODO: Remove this scripting logic once the 2-week FC window has passed.
38953888
if antialias:
3896-
if not torch.jit.is_scripting():
3897-
return torch._C._nn._upsample_bilinear2d_aa(input, output_size, align_corners, scale_factors)
3898-
else:
3899-
raise RuntimeError("TorchScript currently does not support antialias in interpolate")
3889+
return torch._C._nn._upsample_bilinear2d_aa(input, output_size, align_corners, scale_factors)
39003890
return torch._C._nn.upsample_bilinear2d(input, output_size, align_corners, scale_factors)
39013891
if input.dim() == 5 and mode == "trilinear":
39023892
assert align_corners is not None
39033893
return torch._C._nn.upsample_trilinear3d(input, output_size, align_corners, scale_factors)
39043894
if input.dim() == 4 and mode == "bicubic":
39053895
assert align_corners is not None
3906-
# Enforce that the full call with the new kwarg is not invoked when scripting.
3907-
# TODO: Remove this scripting logic once the 2-week FC window has passed.
39083896
if antialias:
3909-
if not torch.jit.is_scripting():
3910-
return torch._C._nn._upsample_bicubic2d_aa(input, output_size, align_corners, scale_factors)
3911-
else:
3912-
raise RuntimeError("TorchScript currently does not support antialias in interpolate")
3897+
return torch._C._nn._upsample_bicubic2d_aa(input, output_size, align_corners, scale_factors)
39133898
return torch._C._nn.upsample_bicubic2d(input, output_size, align_corners, scale_factors)
39143899

39153900
if input.dim() == 3 and mode == "bilinear":

0 commit comments

Comments
 (0)