train_efficientnet is broken still
ADD
examples/train_efficientnet.py
+import time
+import numpy as np
+from efficientnet import EfficientNet
+from tinygrad.tensor import Tensor
+
+if __name__ == "__main__":
+ Tensor.default_gpu = True
+ model = EfficientNet()
+
+ BS = 4
+
+ img = np.zeros((BS,3,224,224), dtype=np.float32)
+
+ st = time.time()
+ out = model.forward(Tensor(img))
+ et = time.time()
+ print("%.2f s" % (et-st))
+

MODIFY
tinygrad/tensor.py
tinygrad/tensor.py
@@ -23,8 +23,11 @@ def require_init_gpu():
class Tensor:
did_float_warning = False
+ default_gpu = False
- def __init__(self, data, gpu=False):
+ def __init__(self, data, gpu=None):
+ if gpu is None:
+ gpu = Tensor.default_gpu
if isinstance(data, list):
data = np.array(data, dtype=np.float32)
elif GPU and isinstance(data, cl._cl.Buffer):

train_efficientnet is broken still