Skip to content

Conversation

@lixiaolei1982
Copy link

Description

Fixed incorrect type annotation for positional_encoding_size parameter in Backbone.__init__ method.

Changes Made

  • Changed type from bool = False to int = 37
  • Matches the expected type in DinoV2 class
  • Improves type safety and developer experience

Testing

  • All existing tests pass
  • Type checkers now validate correctly
  • Backward compatible

Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR fixes an incorrect type annotation for the positional_encoding_size parameter in the Backbone.__init__ method, changing it from bool = False to int = 37 to match the expected type in the DinoV2 class where it's used in arithmetic operations.

Changes:

  • Corrected type annotation from bool to int for positional_encoding_size parameter
  • Updated default value from False to 37

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

patch_size: int = 14,
num_windows: int = 4,
positional_encoding_size: bool = False,
positional_encoding_size: int = 37,
Copy link

Copilot AI Jan 12, 2026

Choose a reason for hiding this comment

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

The change from bool = False to int = 37 is not backward compatible as claimed in the PR description. Code that relies on the default value will break because:

  • Old behavior: False is coerced to 0 in arithmetic operations (e.g., 0 * patch_size = 0)
  • New behavior: 37 * patch_size = 518 (with default patch_size of 14)

This affects the implied_resolution calculation in DinoV2 class at line 89. While the type fix is correct (the parameter should be an int), the default value change is breaking. Consider whether:

  1. This breaking change is acceptable because all configurations explicitly set this parameter
  2. Documentation should be updated to note this breaking change
  3. Migration guidance should be provided for any code using the default value
Suggested change
positional_encoding_size: int = 37,
positional_encoding_size: int = 0,

Copilot uses AI. Check for mistakes.
@Borda Borda added the bug Something isn't working label Jan 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants