convert tensor to gpu
MODIFY
tinygrad/tensor.py
tinygrad/tensor.py
@@ -39,8 +39,7 @@ class Tensor:
self.grad = None
if gpu:
- self.data = self.cuda().data
- self.gpu = True
+ self.cuda_()
# internal variables used for autograd graph construction
self._ctx = None
@@ -104,6 +103,10 @@ class Tensor:
else:
return self
+ def cuda_(self):
+ self.data = self.cuda().data
+ self.gpu = True
+
def cuda(self):
if not GPU:
raise Exception("No GPU Support")

convert tensor to gpu