Skip to content

Fix GCC 14 build failure in graph topological sort - #34068

Open
Tianlei Wu (tianleiwu) with Copilot wants to merge 5 commits into
mainfrom
copilot/fix-build-linux-x64-minsize-rel
Open

Tianlei Wu (tianleiwu) with Copilot wants to merge 5 commits into
mainfrom
copilot/fix-build-linux-x64-minsize-rel

Conversation

Copilot AI commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Description

  • Use std::vector as the priority queue’s backing container in KahnsTopologicalSort, avoiding the GCC 14 -Werror=uninitialized warning triggered by moving an InlinedVector.
  • Retain the heap-based traversal and the session-creation optimizations from PR Speed up session creation #33939.

Motivation and Context

The Linux MinSizeRel build with exceptions disabled failed while compiling graph.cc: GCC 14 treated an Abseil InlinedVector move-constructor warning as an error. This change avoids that move while preserving the priority queue’s ordering.

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Signed-off-by: Christian Bourjau <christian.bourjau@quantco.com>

Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
The ready set was kept in a sorted std::list. Inserting with
std::upper_bound walks the list linearly, so each push cost O(n) in the
queue length. Graphs with many simultaneously ready nodes (e.g., many
Constant nodes without inputs) made every topological sort quadratic.
GraphViewer runs this sort on construction, and most graph transformers
construct a GraphViewer, so session creation was dominated by it.

Replace the list with a std::priority_queue. The visit order is
unchanged: both structures pop the greatest node under `comp`, and
PriorityNodeCompare (the only caller's comparator) is a strict total
order because it breaks ties by node index.

Signed-off-by: Christian Bourjau <christian.bourjau@quantco.com>

Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
ReplaceInputsToUseSharedInitializer copied the shared initializer's
consumer list and searched it linearly before adding each consumer.
That list grows with every replaced duplicate, making the transformer
quadratic in the number of duplicate initializers.

Graph::AddConsumerNode inserts into a set and already ignores
duplicates, so call it unconditionally.

Signed-off-by: Christian Bourjau <christian.bourjau@quantco.com>

Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
Co-authored-by: tianleiwu <30328909+tianleiwu@users.noreply.github.com>
Copilot AI changed the title [WIP] Fix failing GitHub Actions job for Build Linux x64 MinSizeRel Fix GCC 14 build failure in graph topological sort Nov 10, 2026
@tianleiwu
Tianlei Wu (tianleiwu) marked this pull request as ready for review November 10, 2026 04:42
Copilot AI balanced review requested due to automatic review settings November 10, 2026 04:42

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟢 Approval recommended

No active review issues remain for the GCC 14 build fix and related session-creation optimizations.

No open issues 🎉

What changed in this PR

Addresses the GCC 14 build failure in graph topological sorting while retaining the session-creation optimizations from PR #33939.

Changes:

  • Uses a std::vector-backed priority queue to avoid the InlinedVector move warning while preserving heap-based traversal and ordering.
  • Removes redundant consumer lookups during constant sharing.
  • Retrieves tensor element types directly from node type metadata in the allocation planner.
File Description
onnxruntime/​core/​optimizer/​constant_sharing.cc Relies on consumer-set deduplication instead of copying and searching consumers.
onnxruntime/​core/​graph/​graph.cc Uses a vector-backed binary heap for efficient topological traversal.
onnxruntime/​core/​framework/​allocation_planner.cc Avoids indirect type conversion when retrieving tensor element types.

Review effort: Balanced

This branch has not been deployed

No deployments
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.

5 participants