-
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -192,11 +192,11 @@ void lowerSegment( | |
| out, | ||
| DomainType::kLoop, | ||
| {ParallelType::Stream})) { | ||
| auto [i, inserted] = replacement_map.try_emplace( | ||
| in, | ||
| hir::shardByStream(in, innermost.loop->index(), communication)); | ||
| if (inserted) { | ||
| innermost_scope.pushBack(i->second->definition()); | ||
| Val*& sharded_in = replacement_map[in]; | ||
| if (sharded_in == nullptr) { | ||
| sharded_in = | ||
| hir::shardByStream(in, innermost.loop->index(), communication); | ||
| innermost_scope.pushBack(sharded_in->definition()); | ||
| } | ||
| } | ||
|
|
||
|
|
@@ -210,7 +210,7 @@ void lowerSegment( | |
| nullptr) { | ||
| innermost.parent_scope->insert( | ||
| innermost.parent_insertion_point, allocate); | ||
| auto [i, inserted] = replacement_map.try_emplace( | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This is OK because of the |
||
| auto [i, inserted] = replacement_map.emplace( | ||
| out, | ||
| hir::shardByStream(out, innermost.loop->index(), communication)); | ||
| NVF_ERROR(inserted, "The input segmented fusion should be SSA."); | ||
|
|
@@ -314,9 +314,6 @@ void lowerSegment( | |
| innermost.parent_insertion_point, allocate); | ||
| // 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` | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The comment is outdated. |
||
| // is missing. | ||
| TensorView* sharded_out = | ||
| hir::shardByStream(out, innermost.loop->index(), e); | ||
| replacement_map[out] = sharded_out; | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -114,7 +114,7 @@ std::unordered_map<ParallelType, IterDomain*> mapDeviceAndStreamParallelTypeToId | |
| } | ||
|
|
||
| NVF_ERROR( | ||
| parallel_type_to_id.try_emplace(parallel_type, id).second, | ||
|
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ditto |
||
| parallel_type_to_id.emplace(parallel_type, id).second, | ||
| "Found multiple loop IterDomains with the same parallel type (", | ||
| parallel_type, | ||
| "): ", | ||
|
|
||
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.