Skip to content

Commit 73177df

Browse files
committed
Fix scale when output_size is given
1 parent 35085ea commit 73177df

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

src/diffusers/models/upsampling.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@ def forward(self, hidden_states: torch.Tensor, output_size: Optional[int] = None
167167
if self.interpolate:
168168
# upsample_nearest_nhwc also fails when the number of output elements is large
169169
# https://github.com/pytorch/pytorch/issues/141831
170-
scale_factor = 2 if output_size is None else max(output_size)
170+
scale_factor = 2 if output_size is None else max([f/s for f,s in zip(output_size, hidden_states.shape[-2:])])
171171
if hidden_states.numel() * scale_factor > pow(2, 31):
172172
hidden_states = hidden_states.contiguous()
173173

0 commit comments

Comments
 (0)