Validate RNN activation attribute lengths - #31675
Open
apsonawane wants to merge 1 commit into
Open
Conversation
Co-authored-by: Copilot <223556219@users.noreply.github.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR tightens attribute validation for the CPU RNN kernel by enforcing expected lengths for activation_alpha and activation_beta, and adds unit tests to ensure invalid lengths fail model loading with clear error messages.
Changes:
- Enforce
activation_alpha/activation_betavector lengths duringRNNkernel construction. - Add a shared test helper plus two new negative tests validating failure behavior for short activation parameter vectors.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| onnxruntime/core/providers/cpu/rnn/rnn.h | Adds constructor-time activation_alpha/activation_beta length checks for CPU RNN. |
| onnxruntime/test/providers/cpu/rnn/rnn_op_test.cc | Adds helper + new tests that assert model-load failure and error strings for invalid activation parameter lengths. |
Comment on lines
+33
to
+36
| ORT_ENFORCE(activation_alpha_.size() == static_cast<size_t>(num_directions), | ||
| "RNN op: activation_alpha must have ", num_directions, " values. Actual:", activation_alpha_.size()); | ||
| ORT_ENFORCE(activation_beta_.size() == static_cast<size_t>(num_directions), | ||
| "RNN op: activation_beta must have ", num_directions, " values. Actual:", activation_beta_.size()); |
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.
This pull request adds stricter validation for the
activation_alphaandactivation_betaattributes in the RNN operator to ensure they have the correct number of values, and introduces new unit tests to verify that invalid attribute lengths are properly handled with clear error messages.Validation improvements in RNN operator:
activation_alphaandactivation_betavectors have exactlynum_directionselements, with descriptive error messages if the validation fails.Testing for invalid attribute lengths:
RunRnnActivationLengthFailureTestand two new unit tests inrnn_op_test.ccto verify that the RNN operator fails to load whenactivation_alphaoractivation_betahave fewer values than required, and that the correct error messages are produced.