feat: Add `.MemberIsNullIs[type] Functions to TritonJson#157
Merged
Conversation
This change adds a set of .MemberIs[type] functions to TritonJson. * MemberIsArray(const char* name) const * MemberIsArray(const std::string& name) const * MemberIsNull(const char* name) const * MemberIsNull(const std::string& name) const * MemberIsObject(const char* name) const * MemberIsObject(const std::string& name) const * MemberIsString(const char* name) const * MemberIsString(const std::string& name) const These new methods are used in parsing of the JSON blobs returned by PyTorch's AOTInductorContainerRunner::get_call_spec() function to determine the interface the model supports.
Contributor
There was a problem hiding this comment.
Pull request overview
Adds member-level JSON type-check helpers to TritonJson to simplify parsing object members returned by PyTorch’s AOTInductorContainerRunner::get_call_spec().
Changes:
- Added
MemberIsArray/Null/Object/Stringoverloads forconst char*andstd::stringmember names. - Implemented these checks as safe guards that return
falsewhen the value isn’t an object or the member is missing.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
yinggeh
reviewed
May 5, 2026
| { | ||
| const rapidjson::Value& object = AsValue(); | ||
| if (!object.IsObject() || !object.HasMember(name)) | ||
| if (!object.IsObject() || !object.HasMember(name)) { |
Contributor
There was a problem hiding this comment.
Good catch. We should never do no-block one-liner.
yinggeh
approved these changes
May 5, 2026
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 change adds a set of
.MemberIs[type]functions to TritonJson.MemberIsArray(const char* name) constMemberIsArray(const std::string& name) constMemberIsNull(const char* name) constMemberIsNull(const std::string& name) constMemberIsObject(const char* name) constMemberIsObject(const std::string& name) constMemberIsString(const char* name) constMemberIsString(const std::string& name) constThese new methods are used in parsing of the JSON blobs returned by PyTorch's AOTInductorContainerRunner::get_call_spec() function to determine the interface the model supports.