What recompute_scale_factor actually does in interpolate?

I understand that the torch.nn.functional.interpolate first computes the out size(s) using round(size * scale). According to documentation:

If recompute_scale_factor is True, then scale_factor must be passed in and scale_factor is used to compute the output size. The computed output size will be used to infer new scales for the interpolation. Note that when scale_factor is floating-point, it may differ from the recomputed scale_factor due to rounding and precision issues.

How does this recomputed scale factor helps in interpolation when the output size has already been calculated?

When and what difference does it make if I toggle the recompute_scale_factor for the exact same input?

2 Likes