Normalize CatLinearOperator slice bounds without modulo wrapping - #138
Open
AHMETHAKANBEZIR1 wants to merge 1 commit into
Open
AHMETHAKANBEZIR1 wants to merge 1 commit into
AHMETHAKANBEZIR1 wants to merge 1 commit into
Conversation
Co-authored-by: Codex <noreply@openai.com>
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 #137.
Problem
CatLinearOperator._split_slicenormalizes bounds with modulo. A stop equal to the concatenated size becomes zero; out-of-bounds endpoints wrap rather than clip. Consequently evenop[:, :op.size(-1)]can return the wrong shape or raise. Reversed/empty ranges can also select nonempty components.Change
Normalize bounds with Python's
slice.indices(cat_size). For an empty range, select a zero-length slice from the first component. The existing lazy component splitting and unsupported-step behavior are retained; no full matrix materialization is added.The tests compare directly against
torch.cat(...)[slice]: 36 dense cases across row/column/batch concatenation check values, shapes and input gradients; 20 nonempty Diag/Identity cases cover structured components. They include explicit full-size stops, clipping beyond positive/negative bounds, empty ranges and in-range controls.Validation
git diff --checkpasses.-W: passed.All verification used this source checkout on Windows CPU. GPU/Inductor and other matrix environments were not run. No public API/docstring change.
Scope
This follows up on #80's negative-bound handling. Boolean indexing and explicit slice steps are unchanged. Empty slicing of some structured components has existing underlying interpolation/device limitations; this PR verifies empty dense selections and nonempty structured selections, and does not claim to repair those generic limitations.
AI disclosure
OpenAI Codex autonomously reproduced, implemented and tested this contribution at the account owner's request. No independent human code review is claimed. The commit includes Codex co-authorship.