Skip to content

Commit 94c61d4

Browse files
Kutta Srinivasanfacebook-github-bot
authored andcommitted
Fix infinite loop in del_post_hook (#21914)
Summary: Pull Request resolved: #21914 #21591 added a needed feature to clean up grad accumulator post hooks when the DistributedDataParallel model object is cleaned up. There's a minor typo that causes it to loop infinitely over the first element. Differential Revision: D15878884 fbshipit-source-id: b7fd0bbd51eb187579d639b1709c6f7b62b85e7a
1 parent c0f5114 commit 94c61d4

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

torch/csrc/autograd/function.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -261,7 +261,7 @@ struct TORCH_API Function : std::enable_shared_from_this<Function> {
261261

262262
// delete a post hook matching the key
263263
bool del_post_hook(const uintptr_t& key) {
264-
for (auto it = post_hooks_.begin(); it != post_hooks_.end();) {
264+
for (auto it = post_hooks_.begin(); it != post_hooks_.end(); ++it) {
265265
if (key == reinterpret_cast<std::uintptr_t>(it->get())) {
266266
post_hooks_.erase(it);
267267
return true;

0 commit comments

Comments
 (0)