mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-08-29 10:56:08 +00:00
remove Tensor.detach override [pr] (#16239)
This commit is contained in:
@@ -25,8 +25,10 @@ class ElementwiseMixin(DTypeMixin, CreationMixin):
|
||||
def usum(self, *uops) -> Self: return functools.reduce(operator.or_ if self.dtype is dtypes.bool else operator.add, argfix(*uops), self)
|
||||
def uprod(self, *uops) -> Self: return functools.reduce(operator.and_ if self.dtype is dtypes.bool else operator.mul, argfix(*uops), self)
|
||||
|
||||
# NOTE: Tensor overrides this to also set requires_grad=False
|
||||
def detach(self) -> Self:
|
||||
"""
|
||||
Returns a new tensor with the same data as this tensor, but detached from the autograd graph.
|
||||
"""
|
||||
return self.alu(Ops.DETACH)
|
||||
|
||||
def logical_not(self) -> Self:
|
||||
|
||||
@@ -279,12 +279,6 @@ class Tensor(OpMixin):
|
||||
self.uop = assign
|
||||
return self
|
||||
|
||||
def detach(self) -> Tensor:
|
||||
"""
|
||||
Returns a new tensor with the same data as this tensor, but detached from the autograd graph.
|
||||
"""
|
||||
return Tensor(self.uop.detach(), requires_grad=False)
|
||||
|
||||
def _buffer(self) -> Buffer:
|
||||
from tinygrad.engine.realize import capturing
|
||||
if capturing and not getenv("UNSAFE_ALLOW_JIT_BUFFER"):
|
||||
|
||||
Reference in New Issue
Block a user