Skip to content

Commit

Permalink
Minor improvement on the decomposition of upsample_bilinear (#101682)
Browse files Browse the repository at this point in the history
This is how it's done in core.
Pull Request resolved: #101682
Approved by: https://github.com/ngimel
  • Loading branch information
lezcano authored and pytorchmergebot committed May 18, 2023
1 parent ac1cf00 commit 1930428
Showing 1 changed file with 2 additions and 6 deletions.
8 changes: 2 additions & 6 deletions torch/_decomp/decompositions.py
Original file line number Diff line number Diff line change
Expand Up @@ -2780,19 +2780,15 @@ def upsample_bilinear2d(
if align_corners:
h_scale_factor = (in_h - 1) / (out_h - 1)
else:
h_scale_factor = (
in_h / (in_h * scales_h) if scales_h is not None else in_h / out_h
)
h_scale_factor = 1.0 / scales_h if scales_h is not None else in_h / out_h
else:
h_scale_factor = 0.0

if out_w > 1:
if align_corners:
w_scale_factor = (in_w - 1) / (out_w - 1)
else:
w_scale_factor = (
in_w / (in_w * scales_w) if scales_w is not None else in_w / out_w
)
w_scale_factor = 1.0 / scales_w if scales_w is not None else in_w / out_w
else:
w_scale_factor = 0.0

Expand Down

0 comments on commit 1930428

Please sign in to comment.