Repository navigation
Fix spatial_ndim after EnsureChannelFirst adds a channel dim (fixes #… - #9192
Open
sillyfellow21 wants to merge 2 commits into
Open
sillyfellow21 wants to merge 2 commits into
sillyfellow21 wants to merge 2 commits into
Conversation
sillyfellow21
requested review from
KumoLiu,
Nic-Ma and
ericspod
as code owners
October 19, 2026 04:46
Contributor
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the ⚙️ Run configuration
You can disable this status message by setting the Use the checkbox below for a quick retry:
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
for more information, see https://pre-commit.ci
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 #9184
Description
EnsureChannelFirst(channel_dim="no_channel")adds a channel dim to a(H, W, D)tensor, but the cachedspatial_ndimstays atndim - 1 = 2because the constructor assumes dim 0 is already the channel. Any later spatial crop then shifts only the first two axes and silently drops the third axis' affine offset — e.g. a crop origin lands at[15, 25, 30]instead of[15, 25, 35]. The same bug affects 2D input (spatial_ndimwas 1 instead of 2).This patch recomputes
spatial_ndimfrom the affine the momentEnsureChannelFirstadds the channel dim, so downstream transforms (e.g.SpatialCrop) build the full N-axis translation. It only touches the no-channel case and non-batched affines, so nothing else is affected.Types of changes
./runtests.sh -f -u --net --coverage../runtests.sh --quick --unittests --disttests.make htmlcommand in thedocs/folder.