enet is running on GPU
MODIFY
examples/efficientnet.py
examples/efficientnet.py
@@ -94,7 +94,7 @@ class EfficientNet:
x = x.avg_pool2d(kernel_size=x.shape[2:4])
x = x.reshape(shape=(-1, 1280))
#x = x.dropout(0.2)
- return x.dot(self._fc).add(self._fc_bias)
+ return x.dot(self._fc).add(self._fc_bias.reshape(shape=[1,-1]))
def load_weights_from_torch(self):
# load b0
@@ -159,7 +159,7 @@ if __name__ == "__main__":
import time
st = time.time()
if GPU:
- out = model.forward(Tensor(img).cuda())
+ out = model.forward(Tensor(img).cuda()).cpu()
else:
out = model.forward(Tensor(img))

MODIFY
tinygrad/opsgpu.py
tinygrad/opsgpu.py
@@ -47,18 +47,20 @@ def cl_subsample_krnl_build(cl_ctx, iter_op, result_op, init_val=0):
def subsample_op(ctx, input, kernel_size, iter_op, result_op, init_val=0):
N, C, Y, X = input.shape
- ret = buffer_new(ctx, (N, C, Y//2, X//2))
- osize = np.array((X//2, Y//2), dtype=cl.cltypes.uint2)
+ py,px = kernel_size
+ ret = buffer_new(ctx, (N, C, Y//py, X//px))
+ osize = np.array((X//px, Y//py), dtype=cl.cltypes.uint2)
isize = np.array((X, Y), dtype=cl.cltypes.uint2)
- ksize = np.array(kernel_size[::-1], dtype=cl.cltypes.uint2)
+ ksize = np.array((px,py), dtype=cl.cltypes.uint2)
prg = cl_subsample_krnl_build(ctx.cl_ctx, iter_op, result_op, init_val=init_val)
- prg.subsample(ctx.cl_queue, (N*C, Y//2, X//2), None,
+ prg.subsample(ctx.cl_queue, (N*C, Y//py, X//px), None,
ret, input, osize, isize, ksize, np.int32(input.size))
ctx.data = np.empty((N, C, Y, X)) # set shape expectation on tensor instance
return ret
def binary_op(ctx, code, x, y):
- assert len(x.shape) == len(y.shape)
+ if len(x.shape) != len(y.shape):
+ raise Exception("shape mismatch in binop %s: %r %r" % (code, x.shape, y.shape))
xdiv = 1
ydiv = 1
if x.shape != y.shape:

enet is running on GPU