Fix NodeAttrHelper string default lifetime - #32019
Merged
Akshay Sonawane (apsonawane) merged 1 commit intoAug 13, 2026
Merged
Conversation
Akshay Sonawane (apsonawane)
enabled auto-merge (squash)
August 12, 2026 07:41
Ti-Tai Wang (titaiwangms)
approved these changes
Aug 13, 2026
Akshay Sonawane (apsonawane)
deleted the
fix/node-attr-string-default-lifetime
branch
August 13, 2026 17:53
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 pull request enhances the
NodeAttrHelperutility by adding overloads for retrieving string attributes with different types of default values, improving safety and flexibility when handling attribute lookups. It also updates usages to leverage these new overloads and clarifies ownership semantics for returned strings.Node attribute retrieval improvements:
NodeAttrHelper::Getfor string attributes: one that accepts an rvalue (std::string&&) and one that accepts a C-style string (const char*). These overloads return owned strings, ensuring safe return of temporaries or literals. The documentation was updated to clarify that lvalue defaults may be returned by reference, while temporaries and literals are returned as owned strings. (onnxruntime/core/providers/qnn/ort_api.h[1]onnxruntime/core/providers/shared/utils/utils.h[2]NodeAttrHelper. (onnxruntime/core/providers/qnn/ort_api.cc[1]onnxruntime/core/providers/shared/utils/utils.cc[2]<utility>header forstd::moveusage. (onnxruntime/core/providers/shared/utils/utils.cconnxruntime/core/providers/shared/utils/utils.ccR7-R8)Usage updates and bug fixes:
std::stringfor the default value in context binary retrieval, preventing potential dangling reference issues. (onnxruntime/core/providers/qnn/builder/onnx_ctx_model_helper.cconnxruntime/core/providers/qnn/builder/onnx_ctx_model_helper.ccL94-R95)coordinate_transoformation_modeattribute, aligning with the new overloads and preventing reference issues. (onnxruntime/core/providers/vsinpu/builders/impl/resize_op_builder.honnxruntime/core/providers/vsinpu/builders/impl/resize_op_builder.hL72-R72)