Skip to content

Vulkan backend: Add missing include of algorithm - #22422

Open
xuyanwen2012 wants to merge 1 commit into
pytorch:mainfrom
sarc-acl:fix-vulkan-gcc15-missing-algorithm
Open

Vulkan backend: Add missing include of algorithm#22422
xuyanwen2012 wants to merge 1 commit into
pytorch:mainfrom
sarc-acl:fix-vulkan-gcc15-missing-algorithm

Conversation

@xuyanwen2012

@xuyanwen2012 xuyanwen2012 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Problem

backends/vulkan/runtime/graph/containers/SharedObject.cpp and
backends/vulkan/runtime/graph/ops/impl/Squeeze.cpp call std::find
(and Squeeze.cpp also std::rotate) without including <algorithm>.
This compiled previously because the declarations leaked in
transitively through other headers, but GCC 15's libstdc++ header
reorganization removed that transitive path, breaking the build with:

error: no matching function for call to 'find(...)'
note: candidate 1: ... std::find(istreambuf_iterator<...>, ...)

The remaining candidate is a narrow istreambuf_iterator-only overload
pulled in via an unrelated header (<sstream>/<ostream> chain), not
the generic <algorithm> overload these call sites actually need.

This is the same class of issue as #15220 (missing <cstdint> include
in the Vulkan backend) and relates to the GCC 15 CI build failures
that led to disabling executorch-ubuntu-26.04-gcc15 in favor of
gcc14 (#20304, tracked in #19917).

Fix

Add #include <algorithm> to both files, matching the precedent set
in backends/vulkan/runtime/utils/StorageUtils.h (#15220).

Test Plan

Built the vulkan_backend CMake target with GCC 15 (gcc (Ubuntu 15.x)), which fails to compile on main today with the errors above.
With this fix, cmake --build cmake-out --target vulkan_backend
completes cleanly. Swept the rest of backends/vulkan/runtime for the
same pattern (std::find/sort/rotate/etc. without <algorithm>)
and found no other occurrences outside these two files.

cc @SS-JIA @manuelcandales @digantdesai @cbilgin

SharedObject.cpp and Squeeze.cpp call std::find (and Squeeze.cpp also
std::rotate) without including <algorithm>. This compiled previously
because the declarations leaked in transitively through other headers,
but GCC 15's libstdc++ header reorganization removed that transitive
path, breaking the build with:

  error: no matching function for call to 'find(...)'
  note: candidate 1: ... std::find(istreambuf_iterator<...>, ...)

The remaining candidate is a narrow istreambuf_iterator-only overload
pulled in via an unrelated header, not the generic <algorithm> one
these call sites need. Fix by including <algorithm> directly, matching
the precedent in backends/vulkan/runtime/utils/StorageUtils.h (pytorch#15220).

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012pYceHYjdou8JBKdAdzVug
@xuyanwen2012
xuyanwen2012 requested a review from SS-JIA as a code owner September 1, 2026 21:03
Copilot AI lite review requested due to automatic review settings September 1, 2026 21:03
@pytorch-bot pytorch-bot Bot added the module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/ label Sep 1, 2026
@pytorch-bot

pytorch-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

🔗 Helpful Links

🧪 See artifacts and rendered test results at hud.pytorch.org/pr/pytorch/executorch/22422

Note: Links to docs will display an error until the docs builds have been completed.

⚠️ 15 Awaiting Approval

As of commit 645ccbe with merge base 448fbfe (image):

AWAITING APPROVAL - The following workflows need approval before CI can run:

This comment was automatically generated by Dr. CI and updates every 15 minutes.

@meta-cla meta-cla Bot added the CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. label Sep 1, 2026
@linux-foundation-easycla

Copy link
Copy Markdown

CLA Not Signed

One or more co-authors of this pull request were not found. You must specify co-authors in commit message trailer via:

Co-authored-by: name <email>

Supported Co-authored-by: formats include:

  1. Anything <id+login@users.noreply.github.com> - it will locate your GitHub user by id part.
  2. Anything <login@users.noreply.github.com> - it will locate your GitHub user by login part.
  3. Anything <public-email> - it will locate your GitHub user by public-email part. Note that this email must be made public on Github.
  4. Anything <other-email> - it will locate your GitHub user by other-email part but only if that email was used before for any other CLA as a main commit author.
  5. login <any-valid-email> - it will locate your GitHub user by login part, note that login part must be at least 3 characters long.

Alternatively, if the co-author should not be included, remove the Co-authored-by: line from the commit message.

Please update your commit message(s) by doing git commit --amend and then git push [--force] and then request re-running CLA check via commenting on this pull request:

/easycla

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown

This PR needs a release notes: label

If your change should be included in the release notes (i.e. would users of this library care about this change?), please use a label starting with release notes:. This helps us keep track and include your important work in the next release notes.

To add a label, you can comment to pytorchbot, for example
@pytorchbot label "release notes: none"

For more information, see
https://github.com/pytorch/pytorch/wiki/PyTorch-AutoLabel-Bot#why-categorize-for-release-notes-and-how-does-it-work.

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

The changes are minimal, localized, and correctly add missing standard library includes required by the existing code paths.

Pull request overview

This PR fixes a GCC 15 build break in the Vulkan backend by making <algorithm> an explicit dependency in the two .cpp translation units that use std::find (and std::rotate), avoiding reliance on transitive standard library includes.

Changes:

  • Add #include <algorithm> to Squeeze.cpp to cover std::find / std::rotate.
  • Add #include <algorithm> to SharedObject.cpp to cover std::find.
File summaries
File Description
backends/vulkan/runtime/graph/ops/impl/Squeeze.cpp Adds <algorithm> include for std::find/std::rotate used in the implementation.
backends/vulkan/runtime/graph/containers/SharedObject.cpp Adds <algorithm> include for std::find used in SharedObject::has_user.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@xuyanwen2012

Copy link
Copy Markdown
Contributor Author

Additional data point: this isn't strictly GCC-15-specific. Reproduced the identical build failure on a second, unrelated machine running Rocky Linux 10.2 with GCC 14.3.1 (Red Hat 14.3.1-4):

backends/vulkan/runtime/graph/containers/SharedObject.cpp:16:19: error: no matching function for call to 'find(std::vector<int>::const_iterator, std::vector<int>::const_iterator, const vkcompute::ValueRef&)'

Same root cause, same fix (adding #include <algorithm>) resolves it there too. So this is a case of code that was already relying on fragile transitive includes — GCC 15's libstdc++ reorganization is what surfaced it originally, but at least one downstream libstdc++ packaging (Red Hat's GCC 14 build) exposes the same gap. Worth keeping in mind that this class of fix is protecting against more than just the GCC 15 CI image.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

CLA Signed This label is managed by the Facebook bot. Authors need to sign the CLA before a PR can be reviewed. module: vulkan Issues related to the Vulkan delegate and code under backends/vulkan/

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants