Use common dispatch for compiled constants - #4129
Merged
zcbenz merged 2 commits intoAug 11, 2026
Merged
Conversation
zcbenz
reviewed
Aug 10, 2026
| throw std::runtime_error("Unsupported constant type"); | ||
| } | ||
| }); | ||
| if (!printed) { |
Member
There was a problem hiding this comment.
I think this check is redundant?
Contributor
Author
There was a problem hiding this comment.
Thanks — yes, good catch. Given the array dtype invariant, dispatch_all_types covers every current array::dtype() value, so the outer sentinel was redundant. I removed it and reran the 14-dtype text parity, compile/JIT tests (24 cases, 117 assertions), and full C++ suite (247 cases, 3,326 assertions); all pass.
zcbenz
approved these changes
Aug 11, 2026
1 task done
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.
Summary
Replace
print_constant's exhaustive dtype switch withdispatch_all_types.Compile-time capability branches retain the existing bool, byte-integer,
integer, floating, and complex formatting paths for every current dtype.
This removes sixteen net lines from one function.
Testing
compiled.cppRelease translation-unit replay with warnings as errors;the replay matched the stored 41,120-byte object with a 14,836-byte text
section
the int8 and uint8 numeric formatting paths
object and library symbol-name lists are unchanged, while the now-unused
std::runtime_error(char const*)import is removedcompiled_check_contiguityand its call incompiled_collapse_contiguous_dims, notprint_constant; this change addsno new conflict to [Experiment] ROCm backend #2300's existing current-main conflict
clang-formatandgit diff --check