Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -358,14 +358,6 @@ def get_image_size(
resize_height = max(int(round(resize_height / 32) * 32), 32)
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The removed early-return optimization (if resize_height == height and resize_width == width) avoided tensor allocation when no resize was needed. Its removal means every call now allocates a torch.tensor even when input dimensions are already valid — this could add measurable overhead in high-throughput inference pipelines. Consider restoring the check or benchmarking the impact.

resize_width = max(int(round(resize_width / 32) * 32), 32)

if resize_height == height and resize_width == width:
return SizeDict(height=resize_height, width=resize_width), torch.tensor(
[height, width], dtype=torch.float32, device=image.device
)

if resize_width <= 0 or resize_height <= 0:
return None, (None, None)

return SizeDict(height=resize_height, width=resize_width), torch.tensor(
[height, width], dtype=torch.float32, device=image.device
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -429,14 +429,6 @@ def get_image_size(
resize_height = max(int(round(resize_height / 32) * 32), 32)
resize_width = max(int(round(resize_width / 32) * 32), 32)

if resize_height == height and resize_width == width:
return SizeDict(height=resize_height, width=resize_width), torch.tensor(
[height, width], dtype=torch.float32, device=image.device
)

if resize_width <= 0 or resize_height <= 0:
return None, (None, None)

return SizeDict(height=resize_height, width=resize_width), torch.tensor(
[height, width], dtype=torch.float32, device=image.device
)
Expand Down
Loading