Skip to content

Correct narrowing cast of inputs to threshold datatype.#1553

Merged
auphelia merged 9 commits intodevfrom
bugfix/thresholding
Apr 3, 2026
Merged

Correct narrowing cast of inputs to threshold datatype.#1553
auphelia merged 9 commits intodevfrom
bugfix/thresholding

Conversation

@preusser-amd
Copy link
Copy Markdown
Collaborator

@preusser-amd preusser-amd commented Apr 1, 2026

After refactoring RoundAndClipThresholds, we observed cases where the threshold datatype was minimized below the input datatype when the threshold values themselves did not require a larger type. This exposed a bug in the RTL thresholding implementation.
A temporary compiler-side workaround was added to prevent the threshold datatype from being smaller than the input datatype (a67009c).
This PR fixes the issue in the RTL code, allowing the original optimization (threshold dtype < input dtype) to be safely re-enabled.

@preusser-amd preusser-amd requested a review from auphelia April 1, 2026 19:28
Copy link
Copy Markdown
Collaborator

@auphelia auphelia left a comment

Choose a reason for hiding this comment

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

Thank you, @preusser ! That solved the issue with the MobileNet-v1 Thresholding layer. But the added unit test exposed that there might still be an issue. Will discuss internally.

@auphelia
Copy link
Copy Markdown
Collaborator

auphelia commented Apr 3, 2026

The issue that was revealed by the unit test was addressed in the compiler code. If the MinimizeWeightBitWidth() transform results in WT < WI, we ensure that WT gets expanded to retain the ability to represent all values in [thresh_min-1:thresh_max] to be compatible with the comparison scheme that is done in the RTL Thresholding layer.

@auphelia auphelia merged commit 74d2825 into dev Apr 3, 2026
2 checks passed
@auphelia auphelia deleted the bugfix/thresholding branch April 3, 2026 14:36
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.

3 participants