Vulkan backend: Add missing include of algorithm - #22422
Conversation
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
🔗 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.
|
One or more co-authors of this pull request were not found. You must specify co-authors in commit message trailer via: Supported
Alternatively, if the co-author should not be included, remove the Please update your commit message(s) by doing |
This PR needs a
|
There was a problem hiding this comment.
🟢 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>toSqueeze.cppto coverstd::find/std::rotate. - Add
#include <algorithm>toSharedObject.cppto coverstd::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.
|
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): Same root cause, same fix (adding |
Problem
backends/vulkan/runtime/graph/containers/SharedObject.cppandbackends/vulkan/runtime/graph/ops/impl/Squeeze.cppcallstd::find(and
Squeeze.cppalsostd::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:
The remaining candidate is a narrow
istreambuf_iterator-only overloadpulled in via an unrelated header (
<sstream>/<ostream>chain), notthe generic
<algorithm>overload these call sites actually need.This is the same class of issue as #15220 (missing
<cstdint>includein the Vulkan backend) and relates to the GCC 15 CI build failures
that led to disabling
executorch-ubuntu-26.04-gcc15in favor ofgcc14 (#20304, tracked in #19917).
Fix
Add
#include <algorithm>to both files, matching the precedent setin
backends/vulkan/runtime/utils/StorageUtils.h(#15220).Test Plan
Built the
vulkan_backendCMake target with GCC 15 (gcc (Ubuntu 15.x)), which fails to compile onmaintoday with the errors above.With this fix,
cmake --build cmake-out --target vulkan_backendcompletes cleanly. Swept the rest of
backends/vulkan/runtimefor thesame pattern (
std::find/sort/rotate/etc. without<algorithm>)and found no other occurrences outside these two files.
cc @SS-JIA @manuelcandales @digantdesai @cbilgin