-
Notifications
You must be signed in to change notification settings - Fork 74
Fix several incorrect uses of try_emplace #5755
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
Conversation
|
!test |
| {ParallelType::Stream})) { | ||
| auto [i, inserted] = replacement_map.try_emplace( | ||
| in, | ||
| hir::shardByStream(in, innermost.loop->index(), communication)); |
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.
I misunderstood try_emplace's lazy construction. shardByStream will be called anyway regardless of the key.
Greptile SummaryThis PR fixes incorrect uses of Key changes:
Confidence Score: 5/5
Important Files Changed
Sequence DiagramsequenceDiagram
participant LowerSegment as lowerSegment()
participant ReplacementMap as replacement_map
participant ShardByStream as hir::shardByStream()
Note over LowerSegment: Processing Communication exprs
LowerSegment->>ReplacementMap: Check if 'in' exists using operator[]
alt in is nullptr (not found)
LowerSegment->>ShardByStream: Call shardByStream(in, ...)
ShardByStream-->>ReplacementMap: Store sharded_in
LowerSegment->>LowerSegment: pushBack(definition())
else in exists (not nullptr)
Note over LowerSegment: Skip - already sharded
end
Note over LowerSegment: Processing output allocation
LowerSegment->>ReplacementMap: emplace(out, sharded_out)
alt Insertion succeeds
Note over LowerSegment: SSA property maintained
LowerSegment->>LowerSegment: pushBack(definition())
else Insertion fails
LowerSegment->>LowerSegment: NVF_ERROR - SSA violation
end
Note over LowerSegment: ExprEval case
loop For each input
LowerSegment->>ReplacementMap: contains(in)?
alt Not in map
LowerSegment->>ShardByStream: shardByStream(in, ...)
ShardByStream-->>ReplacementMap: Store via operator[]
end
end
loop For each output
LowerSegment->>ReplacementMap: Check !contains(out)
Note over LowerSegment: SSA check via NVF_ERROR
LowerSegment->>ReplacementMap: Store via operator[]
end
|
| nullptr) { | ||
| innermost.parent_scope->insert( | ||
| innermost.parent_insertion_point, allocate); | ||
| auto [i, inserted] = replacement_map.try_emplace( |
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.
This is OK because of the assert inserted below. However, it's not necessary because the value type, Val*, doesn't involve construction.
| } | ||
|
|
||
| NVF_ERROR( | ||
| parallel_type_to_id.try_emplace(parallel_type, id).second, |
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.
ditto
| // Loop is stream parallelized but allocation is not. Therefore, | ||
| // `out` should be allocated outside the loop. | ||
| // | ||
| // I use try_emplace here so shardByStream is called only when `out` |
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.
The comment is outdated.
|
Review updated until commit 21a25dd Description
|
| Relevant files | |||||
|---|---|---|---|---|---|
| Bug fix |
|
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 |
Behavioral Change in Duplicate Detection
|
|
!test |
mdavis36
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.
LGTM
|
!test |
No description provided.