Skip to content

Conversation

pfultz2
Copy link
Collaborator

@pfultz2 pfultz2 commented Oct 9, 2025

Motivation

LRN ref version does produce correct values when size <= 4.

Technical Details

The scale was set to zero outside of the loop, which was incorrect.

Changelog Category

    • Added: New functionality.
    • Changed: Changes to existing functionality.
    • Removed: Functionality or support that has been removed. (Compared to a previous release)
    • Optimized: Component performance that has been optimized or improved.
    • Resolved Issues: Known issues from a previous version that have been resolved.
    • Not Applicable: This PR is not to be included in the changelog.

@pfultz2 pfultz2 requested a review from causten as a code owner October 9, 2025 22:55
Copy link

codecov bot commented Oct 10, 2025

Codecov Report

✅ All modified and coverable lines are covered by tests.

Additional details and impacted files
@@           Coverage Diff            @@
##           develop    #4370   +/-   ##
========================================
  Coverage    92.26%   92.26%           
========================================
  Files          560      560           
  Lines        26358    26358           
========================================
  Hits         24319    24319           
  Misses        2039     2039           
Files with missing lines Coverage Δ
src/targets/ref/lowering.cpp 94.66% <100.00%> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@causten causten requested a review from Copilot October 10, 2025 15:45
Copy link

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull Request Overview

This PR fixes a bug in the Local Response Normalization (LRN) reference implementation where incorrect values were produced when the LRN size was <= 4. The fix involves moving the scale variable initialization inside the channel loop and improving numerical precision.

  • Moved scale variable initialization from outside to inside the channel loop to ensure correct per-channel computation
  • Changed data types from float to double for better numerical precision
  • Replaced std::pow(x, 2) with direct multiplication (x * x) for performance
  • Added test cases for smaller LRN sizes (3 and 4) to prevent regression

Reviewed Changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
src/targets/ref/lowering.cpp Fixed LRN scale computation bug and improved numerical precision
test/verify/test_lrn.cpp Added test coverage for smaller LRN sizes that were previously failing

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

@causten causten merged commit 397ae3a into develop Oct 10, 2025
49 of 51 checks passed
@causten causten deleted the lrn-ref-fix branch October 10, 2025 18:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants