update replay graph and optimze memory usage.

This commit is contained in:
wbigat
2023-05-11 16:20:27 +08:00
parent 6acebe4da4
commit e0e2e829e3
+3 -2
View File
@@ -65,8 +65,9 @@ class WrapModule(object):
if self.cur_step < self.warm_up_step or not replay_cache:
self.cur_step = self.cur_step + 1
for p in self.module.parameters():
p.grad = torch.zeros_like(p)
if self.requires_grad:
for p in self.module.parameters():
p.grad = torch.zeros_like(p)
shallow_args = ()
fwd_inputs = []
for arg in args: