bidiphase.shift: copy the source slice before the overlapping in-place assignment - #1266
Open
cindykrafft wants to merge 1 commit into
Open
cindykrafft wants to merge 1 commit into
cindykrafft wants to merge 1 commit into
Conversation
…e assignment bidiphase.shift shifts the odd scan lines with an in-place assignment whose source and destination slices overlap. numpy handles overlapping assignments by making a temporary copy, but torch.Tensor.copy_ does not, so since the registration path started passing torch tensors (v1.0.0.1) every odd line was corrupted instead of shifted: with bidiphase=3, 34% of odd-line pixels in register_frames' output differ from the intended shift (they contain repeated copies of the first columns). The reference image, which still goes through the numpy path in registration_wrapper, was shifted correctly, so frames and reference disagreed. Copy the source slice first (clone for torch, copy for numpy), which restores the numpy semantics for both array types. Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_012d2sJAD5EUp4GqAStqoBX7
This branch has not been deployed
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.
Fixes #1265.
bidiphase.shiftshifts the odd scan lines with an in-place assignment whose source and destination slices overlap. numpy handles that with a temporary copy;torch.Tensor.copy_does not, so since the registration path started passing torch tensors (v1.0.0.1) every odd line was corrupted instead of shifted (withbidiphase=3, 34 % of odd-line pixels inregister_frames' output differ from the intended shift), while the reference image — still shifted through the numpy path inregistration_wrapper— was correct.This copies the source slice first (
clone()for torch,copy()for numpy), restoring the numpy semantics for both array types. Verified on 1.1.0 + this patch:register_frames(..., bidiphase=3)reproduces the numpy result exactly, for positive and negative offsets.🤖 Generated with Claude Code
https://claude.ai/code/session_012d2sJAD5EUp4GqAStqoBX7