mirror of
https://github.com/tinygrad/tinygrad.git
synced 2026-01-09 15:08:02 -05:00
no read out of bounds
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -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)),
|
||||
|
||||
Reference in New Issue
Block a user