-
Notifications
You must be signed in to change notification settings - Fork 1.5k
fix: use register_buffer for kernel and kernel_vol in LocalNormalizedCrossCorrelationLoss #8818
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -111,9 +111,8 @@ def __init__( | |
| raise ValueError(f"kernel_size must be odd, got {self.kernel_size}") | ||
|
|
||
| _kernel = look_up_option(kernel_type, kernel_dict) | ||
| self.kernel = _kernel(self.kernel_size) | ||
| self.kernel.require_grads = False | ||
| self.kernel_vol = self.get_kernel_vol() | ||
| self.register_buffer("kernel", _kernel(self.kernel_size)) | ||
| self.register_buffer("kernel_vol", self.get_kernel_vol()) | ||
|
Comment on lines
113
to
+115
|
||
|
|
||
| self.smooth_nr = float(smooth_nr) | ||
| self.smooth_dr = float(smooth_dr) | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Add regression tests for the new buffer semantics.
Line 114 and Line 115 change state behavior, but current tests only validate numerics/error paths. Please add assertions that
kernelandkernel_volare present instate_dict, remain non-parameter buffers, and move with module device changes.As per coding guidelines, "Ensure new or modified definitions will be covered by existing or new unit tests."
🤖 Prompt for AI Agents