Update cupy/_creation/basic.py
@@ -111,9 +111,7 @@ def eye(N, M=None, k=0, dtype=float, order='C'):
if M is None:
M = N
ret = zeros((N, M), dtype=dtype, order=order)
- if k >= M:
- return ret
- if k <= -N:
+ if k <= -N or k >= M:
return ret
ret.diagonal(k)[:] = 1
return ret
