fix: SAM ModelSamVisionLayer missing batch size#262
Open
ziyuanguo1998 wants to merge 2 commits intomainfrom
Open
fix: SAM ModelSamVisionLayer missing batch size#262ziyuanguo1998 wants to merge 2 commits intomainfrom
ziyuanguo1998 wants to merge 2 commits intomainfrom
Conversation
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR fixes the ModSamVisionLayer class in the SAM ViT Base QNN model patches to correctly handle batch sizes greater than 1 in the window_partition and window_unpartition methods, and aligns the forward return type with its declared signature.
Changes:
- Added the
batch_sizedimension toreshapecalls inwindow_partitionandwindow_unpartition, and updated the correspondingpermuteorderings from 5D to 6D to correctly handle arbitrary batch sizes. - Wrapped the
forwardmethod's return value in a tuple to match the declared return type annotationtuple[torch.FloatTensor].
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
You can also share your feedback on Copilot code review. Take the survey.
shaahji
approved these changes
Mar 19, 2026
xieofxie
requested changes
Mar 20, 2026
Contributor
xieofxie
left a comment
There was a problem hiding this comment.
This change is intentional as when we created this recipe, 6D or higher transfomations were not supported and removing batch_size reduced the dimensions to 5D
olive-ai==0.9.3, transformers==4.56.2 and torch==2.8.0 works
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
No description provided.