convert tensor to gpu
@@ -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")
