mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-06-15 09:33:03 +08:00
[experimenting] use contiguous instead of realize in optim (#3770)
* run CI
* comment
* remove t.grad to try
* Revert "remove t.grad to try"
This reverts commit 05ec2d3b89.
This commit is contained in:
@@ -34,10 +34,9 @@ class SGD(Optimizer):
|
||||
def step(self) -> None:
|
||||
for i, t in enumerate(self.params):
|
||||
assert t.grad is not None
|
||||
# this is needed since the grads can form a "diamond"
|
||||
# contiguous is needed since the grads can allegedly form a "diamond"
|
||||
# TODO: fix this in lazy.py
|
||||
t.grad.realize()
|
||||
g = t.grad + self.wd * t.detach()
|
||||
g = t.grad.contiguous() + self.wd * t.detach()
|
||||
if self.momentum:
|
||||
self.b[i].assign(self.momentum * self.b[i] + g) # NOTE: self.b[i] is zero on the first run, no if required
|
||||
g = (g + self.momentum * self.b[i]) if self.nesterov else self.b[i]
|
||||
|
||||
Reference in New Issue
Block a user