mirror of
https://github.com/pytorch/pytorch.git
synced 2025-10-20 21:14:14 +08:00
Use insert_or_assign instead of erase+emplace (#164868)
insert_or_assign does effectively the same thing as erase+emplace but more efficiently since the search does not need to be repeated Pull Request resolved: https://github.com/pytorch/pytorch/pull/164868 Approved by: https://github.com/eqy
This commit is contained in:
committed by
PyTorch MergeBot
parent
37c6087334
commit
a4110fedcf
@ -337,8 +337,7 @@ struct BenchmarkCache {
|
||||
engine_cache_order.begin(), engine_cache_order, it->second.second);
|
||||
}
|
||||
} else {
|
||||
engine_cache.erase(key);
|
||||
engine_cache.emplace(
|
||||
engine_cache.insert_or_assign(
|
||||
key,
|
||||
std::make_pair(results, engine_cache_order.end())); // dummy iterator
|
||||
}
|
||||
|
||||
@ -371,8 +371,7 @@ struct MHAGraphCache {
|
||||
}
|
||||
|
||||
void update(const KeyType& key, T& results) {
|
||||
engine_cache.erase(key);
|
||||
engine_cache.emplace(key, std::move(results));
|
||||
engine_cache.insert_or_assign(key, std::move(results));
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user