ORT 1.28.1 Cherry Picks, pt. 2 - #32098
Merged
Tianlei Wu (tianleiwu) merged 2 commits intoAug 17, 2026
Merged
Conversation
This pull request improves the robustness of the FastGelu fusion optimization by ensuring malformed nodes are properly skipped and adds a test to verify this behavior. The main changes include stricter input validation in the fusion logic and a new unit test. **Fusion logic improvements:** * Added explicit checks for the number of inputs (`InputDefs().size()`) in `Mul` and `Pow` nodes within the `FastGeluFusion` optimizer to ensure only well-formed nodes are considered for fusion. [[1]](diffhunk://#diff-8f18e5c2ad33a6cc11a340f2c0ff3ce5ad63beed1dcc31ea49f1ff409ef030c9R39) [[2]](diffhunk://#diff-8f18e5c2ad33a6cc11a340f2c0ff3ce5ad63beed1dcc31ea49f1ff409ef030c9L89-R91) [[3]](diffhunk://#diff-8f18e5c2ad33a6cc11a340f2c0ff3ce5ad63beed1dcc31ea49f1ff409ef030c9R119) **Testing enhancements:** * Introduced a new test, `FastGeluFusionSkipsMalformedScaleMul`, that modifies a model to create a malformed `Mul` node and verifies that the fusion optimizer correctly skips it (i.e., does not produce a `FastGelu` node).
This pull request introduces stricter validation and error handling for initializers with in-memory external data references in ONNX Runtime's graph handling. The main goal is to ensure that all such references are properly registered and that their data matches expectations, preventing invalid model states and improving robustness. Additionally, new tests are added to verify these behaviors. **Validation and Error Handling Improvements:** * Added a new `ValidateInMemoryInitializers` method to the `Graph` class, which checks that all in-memory external data initializers have corresponding `OrtValue` objects with matching data, and integrated this validation into the graph transformation process. [[1]](diffhunk://#diff-aaea1507ec81a94c72a1fa72ce320df712156b665f7798573be3f7e439bb4c37R1579-R1583) [[2]](diffhunk://#diff-e231a92b40d89409cc8e82436be0a15bc87ef95c93b303b9feaeab6e50c8835cR4000-R4023) [[3]](diffhunk://#diff-3e2227e1225091e8b74c02688e23b21630d1393dd395e15966558901538dd2c7R1549-R1551) * Introduced a helper function `GetValidatedInMemoryInitializer` in `graph_utils.cc` to enforce that in-memory external data initializers are registered and their data matches, replacing ad-hoc checks in various code paths. * Updated `MakeInitializerCopyIfNotExist` and `ConvertInMemoryDataToInline` to use the new validation helper, ensuring consistent and early detection of invalid initializer states. [[1]](diffhunk://#diff-0791c3ebdddb6f4be85d07b707d494551597574eb4f198b0a476d6602c7e2d8bR495-L496) [[2]](diffhunk://#diff-0791c3ebdddb6f4be85d07b707d494551597574eb4f198b0a476d6602c7e2d8bR530) **Testing Enhancements:** * Added the `RejectsUnregisteredInMemoryInitializerCopy` test to verify that the system correctly rejects initializers with arbitrary or unregistered in-memory references, both during validation and when attempting to copy such initializers.
adrastogi
requested review from
Akshay Sonawane (apsonawane) and
Tianlei Wu (tianleiwu)
August 14, 2026 21:26
Tianlei Wu (tianleiwu)
approved these changes
Aug 14, 2026
Akshay Sonawane (apsonawane)
approved these changes
Aug 17, 2026
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 cherry-picks the following commits for the release: