no read out of bounds
MODIFY
README.md
README.md
@@ -112,7 +112,7 @@ Relu, Log, Exp # unary ops
Add, Sub, Mul, Pow # binary ops (with broadcasting)
Sum, Max # reduce ops (with axis argument)
Reshape, Transpose, Slice # movement ops
-Matmul, Conv2D # heavy data processing ops
+Matmul, Conv2D # processing ops
```
While more ops may be added (like Sign), I think these base 14 are stable.

MODIFY
tinygrad/ops_gpu.py
tinygrad/ops_gpu.py
@@ -311,12 +311,11 @@ def inner_slice(ctx, x, arg):
int zero = 1;
for (int dim = 0; dim < n_dims; dim++) {
prod /= shape_ret[dim];
- int tidx = (gid / prod) % shape_ret[dim];
- int sidx = tidx + shift[dim];
+ int sidx = (gid / prod) % shape_ret[dim] + shift[dim];
zero &= (sidx >= 0 && sidx < shape_x[dim]);
iptr = (iptr * shape_x[dim]) + sidx;
}
- output[gid] = input[iptr] * zero;
+ output[gid] = zero ? input[iptr] : 0.0;
}""")
gslice(ctx.cl_queue, [np.prod(ret.shape)], None,
x.cl, ret.cl, i32(np.prod(ret.shape)), i32(len(ret.shape)),

no read out of bounds