-
Notifications
You must be signed in to change notification settings - Fork 75
Use C++20 concepts to replace SFINAE in dynamic_type #5878
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
!test |
Description
|
| Relevant files | |||
|---|---|---|---|
| Enhancement |
|
PR Reviewer Guide
Here are some key observations to aid the review process:
| 🧪 No relevant tests |
| 🔒 No security concerns identified |
| ⚡ Recommended focus areas for review |
Missing Tests
|
Test failures
-
(Medium, 1)
Thunder vs Torch output mismatch in nanogpt autograd (test_networks)Test Name GB200 Source thunder.tests.test_networks.test_nanogpt_complete_autograd_nvfuser_cuda_thunder.dtypes.float32 ❌
Greptile OverviewGreptile SummaryThis PR modernizes the Key changes:
Benefits:
Impact:
Confidence Score: 4/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant User as User Code
participant DT as DynamicType Template
participant SFINAE as SFINAE (Before)
participant Concepts as Concepts (After)
participant Compiler as Compiler
Note over User,Compiler: Template Instantiation Flow
User->>DT: Instantiate DynamicType<T>(value)
rect rgb(200, 150, 150)
Note over DT,SFINAE: Before: SFINAE Approach
DT->>SFINAE: Check std::enable_if_t<condition>
SFINAE->>Compiler: Evaluate complex nested template
Compiler-->>SFINAE: Substitution success/failure
SFINAE-->>DT: Enable/disable overload
end
rect rgb(150, 200, 150)
Note over DT,Concepts: After: Concepts Approach
DT->>Concepts: Evaluate requires clause
Concepts->>Compiler: Direct constraint check
Compiler-->>Concepts: Constraint satisfied/not satisfied
Concepts-->>DT: Enable/disable overload
end
DT-->>User: Constructed object or compile error
Note over User,Compiler: Concepts provide clearer errors and faster compilation
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
2 files reviewed, 2 comments
wujingyue
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For my education, is requires always better than std::enable_if?
|
|
||
| template <typename T, typename = decltype(VariantType(std::declval<T>()))> | ||
| template <typename T> | ||
| requires requires { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double "requires"?
Build time is comparable to pre-change, but this is an incremental step for landing #5747
Before:
After: