remove *0 hack in sign, gradient materializes zeros for unconnected nodes (#15416)

Amp-Thread-ID: https://ampcode.com/threads/T-019d1612-6322-706b-a94d-a812400a55cb

Co-authored-by: Amp <[email protected]>
This commit is contained in:
gg
2026-03-22 12:49:26 -04:00
committed by GitHub
co-authored by Amp
parent c7b18e6108
commit 2087df814f
+1 -1
View File
@@ -677,7 +677,7 @@ class ElementwiseMixin(DTypeMixin):
print(Tensor([-3., -2., -1., 0., 1., 2., 3.]).sign().numpy())
```
"""
return self.ne(0).where((self < 0).where(self.const_like(-1), self.const_like(1)), self.const_like(0)) + self * 0
return self.ne(0).where((self < 0).where(self.const_like(-1), self.const_like(1)), self.const_like(0))
def abs(self) -> Self:
"""