mirror of
https://github.com/pytorch/pytorch.git
synced 2026-11-20 09:04:25 +08:00
[nn] add set_to_none flag for C++ optim endpoint (#92989)
Pull Request resolved: https://github.com/pytorch/pytorch/pull/92989 Approved by: https://github.com/ngimel, https://github.com/Skylion007
This commit is contained in:
committed by
PyTorch MergeBot
parent
dbeb513192
commit
819bd5b77a
@@ -435,8 +435,7 @@ TEST(OptimTest, ZeroGrad) {
|
||||
optimizer.zero_grad();
|
||||
|
||||
for (const auto& parameter : model->parameters()) {
|
||||
ASSERT_TRUE(parameter.grad().defined());
|
||||
ASSERT_EQ(parameter.grad().sum().item<float>(), 0);
|
||||
ASSERT_FALSE(parameter.grad().defined());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user