Skip to content

ORT 1.28.1 Cherry Picks, pt. 2 - #32098

Merged
Tianlei Wu (tianleiwu) merged 2 commits into
rel-1.28.1from
adrastogi/1.28.1-cherry-picks-2
Aug 17, 2026
Merged

ORT 1.28.1 Cherry Picks, pt. 2#32098
Tianlei Wu (tianleiwu) merged 2 commits into
rel-1.28.1from
adrastogi/1.28.1-cherry-picks-2

Conversation

@adrastogi

Copy link
Copy Markdown
Contributor

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.
@tianleiwu
Tianlei Wu (tianleiwu) merged commit 5181af9 into rel-1.28.1 Aug 17, 2026
75 checks passed
@tianleiwu
Tianlei Wu (tianleiwu) deleted the adrastogi/1.28.1-cherry-picks-2 branch August 17, 2026 17:23
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