[incubator-mxnet] 39/42: numpy eye op (#15282)

2019-07-26 Thread haoj
This is an automated email from the ASF dual-hosted git repository.

haoj pushed a commit to branch numpy
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit e080ceb049548b8628e2d756b646ee0bf9072612
Author: Jake Lee 
AuthorDate: Fri Jul 12 03:18:53 2019 -0700

numpy eye op (#15282)

address the comment
---
 python/mxnet/ndarray/numpy/_op.py  |  33 +-
 python/mxnet/numpy/multiarray.py   |  29 -
 python/mxnet/symbol/numpy/_symbol.py   |  33 +-
 src/operator/numpy/np_init_op.cc   |  30 -
 src/operator/numpy/np_init_op.cu   |   5 +-
 src/operator/numpy/np_init_op.h| 113 +
 src/operator/tensor/init_op.h  |  40 +++-
 tests/python/unittest/test_numpy_op.py |  69 
 8 files changed, 314 insertions(+), 38 deletions(-)

diff --git a/python/mxnet/ndarray/numpy/_op.py 
b/python/mxnet/ndarray/numpy/_op.py
index 7f710a0..ff0e8c8 100644
--- a/python/mxnet/ndarray/numpy/_op.py
+++ b/python/mxnet/ndarray/numpy/_op.py
@@ -30,7 +30,7 @@ from ..ndarray import NDArray
 
 __all__ = ['zeros', 'ones', 'maximum', 'minimum', 'stack', 'arange', 'argmax',
'add', 'subtract', 'multiply', 'divide', 'mod', 'power', 
'concatenate',
-   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace',
+   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace', 
'eye',
'sin', 'cos', 'sinh', 'cosh', 'log10', 'sqrt', 'abs', 'exp', 
'arctan', 'sign', 'log',
'degrees', 'log2', 'rint', 'radians', 'mean', 'reciprocal', 
'square', 'arcsin',
'argsort']
@@ -997,6 +997,37 @@ def linspace(start, stop, num=50, endpoint=True, 
retstep=False, dtype=None, axis
 return _npi.linspace(start=start, stop=stop, num=num, 
endpoint=endpoint, ctx=ctx, dtype=dtype)
 
 
+@set_module('mxnet.ndarray.numpy')
+def eye(N, M=None, k=0, dtype=_np.float32, **kwargs):
+"""
+Return a 2-D array with ones on the diagonal and zeros elsewhere.
+
+Parameters
+--
+N : int
+Number of rows in the output.
+M : int, optional
+Number of columns in the output. If None, defaults to N.
+k : int, optional
+Index of the diagonal: 0 (the default) refers to the main diagonal,
+a positive value refers to an upper diagonal,
+and a negative value to a lower diagonal.
+dtype : data-type, optional
+Data-type of the returned array.
+
+Returns
+---
+I : ndarray of shape (N,M)
+An array where all elements are equal to zero,
+except for the k-th diagonal, whose values are equal to one.
+"""
+_sanity_check_params('eye', ['order'], kwargs)
+ctx = kwargs.pop('ctx', current_context())
+if ctx is None:
+ctx = current_context()
+return _npi.eye(N, M, k, ctx, dtype)
+
+
 def _unary_func_helper(x, fn_array, fn_scalar, out=None, **kwargs):
 """Helper function for unary operators.
 
diff --git a/python/mxnet/numpy/multiarray.py b/python/mxnet/numpy/multiarray.py
index cafc656..83fcfc1 100644
--- a/python/mxnet/numpy/multiarray.py
+++ b/python/mxnet/numpy/multiarray.py
@@ -45,7 +45,7 @@ from ..ndarray.numpy import _internal as _npi
 
 __all__ = ['ndarray', 'empty', 'array', 'zeros', 'ones', 'maximum', 'minimum', 
'stack', 'arange',
'argmax', 'add', 'subtract', 'multiply', 'divide', 'mod', 'power', 
'concatenate',
-   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace', 
'sin', 'cos',
+   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace', 
'eye', 'sin', 'cos',
'sin', 'cos', 'sinh', 'cosh', 'log10', 'sqrt', 'abs', 'exp', 
'arctan', 'sign', 'log',
'degrees', 'log2', 'rint', 'radians', 'mean', 'reciprocal', 
'square', 'arcsin',
'argsort']
@@ -2144,6 +2144,33 @@ def linspace(start, stop, num=50, endpoint=True, 
retstep=False, dtype=None, axis
 
 
 @set_module('mxnet.numpy')
+def eye(N, M=None, k=0, dtype=_np.float32, **kwargs):
+"""
+Return a 2-D array with ones on the diagonal and zeros elsewhere.
+
+Parameters
+--
+N : int
+Number of rows in the output.
+M : int, optional
+Number of columns in the output. If None, defaults to N.
+k : int, optional
+Index of the diagonal: 0 (the default) refers to the main diagonal,
+a positive value refers to an upper diagonal,
+and a negative value to a lower diagonal.
+dtype : data-type, optional
+Data-type of the returned array.
+
+Returns
+---
+I : ndarray of shape (N,M)
+An array where all elements are equal to zero,
+except for the k-th diagonal, whose values are equal to one.
+"""
+return _mx_nd_np.eye(N, M, k, dtype, **kwargs)
+
+
+@set_module('mxnet.numpy')
 def sin(x, out=None, **kwargs):
 r"""Trigonometric sine, element-wise.
 
diff --git 

[incubator-mxnet] 39/42: numpy eye op (#15282)

2019-07-24 Thread haoj
This is an automated email from the ASF dual-hosted git repository.

haoj pushed a commit to branch numpy
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit 88e4718a3bcd8dadb0b68df2aec0f5dc461e1226
Author: Jake Lee 
AuthorDate: Fri Jul 12 03:18:53 2019 -0700

numpy eye op (#15282)

address the comment
---
 python/mxnet/ndarray/numpy/_op.py  |  33 +-
 python/mxnet/numpy/multiarray.py   |  29 -
 python/mxnet/symbol/numpy/_symbol.py   |  33 +-
 src/operator/numpy/np_init_op.cc   |  30 -
 src/operator/numpy/np_init_op.cu   |   5 +-
 src/operator/numpy/np_init_op.h| 113 +
 src/operator/tensor/init_op.h  |  40 +++-
 tests/python/unittest/test_numpy_op.py |  69 
 8 files changed, 314 insertions(+), 38 deletions(-)

diff --git a/python/mxnet/ndarray/numpy/_op.py 
b/python/mxnet/ndarray/numpy/_op.py
index 7f710a0..ff0e8c8 100644
--- a/python/mxnet/ndarray/numpy/_op.py
+++ b/python/mxnet/ndarray/numpy/_op.py
@@ -30,7 +30,7 @@ from ..ndarray import NDArray
 
 __all__ = ['zeros', 'ones', 'maximum', 'minimum', 'stack', 'arange', 'argmax',
'add', 'subtract', 'multiply', 'divide', 'mod', 'power', 
'concatenate',
-   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace',
+   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace', 
'eye',
'sin', 'cos', 'sinh', 'cosh', 'log10', 'sqrt', 'abs', 'exp', 
'arctan', 'sign', 'log',
'degrees', 'log2', 'rint', 'radians', 'mean', 'reciprocal', 
'square', 'arcsin',
'argsort']
@@ -997,6 +997,37 @@ def linspace(start, stop, num=50, endpoint=True, 
retstep=False, dtype=None, axis
 return _npi.linspace(start=start, stop=stop, num=num, 
endpoint=endpoint, ctx=ctx, dtype=dtype)
 
 
+@set_module('mxnet.ndarray.numpy')
+def eye(N, M=None, k=0, dtype=_np.float32, **kwargs):
+"""
+Return a 2-D array with ones on the diagonal and zeros elsewhere.
+
+Parameters
+--
+N : int
+Number of rows in the output.
+M : int, optional
+Number of columns in the output. If None, defaults to N.
+k : int, optional
+Index of the diagonal: 0 (the default) refers to the main diagonal,
+a positive value refers to an upper diagonal,
+and a negative value to a lower diagonal.
+dtype : data-type, optional
+Data-type of the returned array.
+
+Returns
+---
+I : ndarray of shape (N,M)
+An array where all elements are equal to zero,
+except for the k-th diagonal, whose values are equal to one.
+"""
+_sanity_check_params('eye', ['order'], kwargs)
+ctx = kwargs.pop('ctx', current_context())
+if ctx is None:
+ctx = current_context()
+return _npi.eye(N, M, k, ctx, dtype)
+
+
 def _unary_func_helper(x, fn_array, fn_scalar, out=None, **kwargs):
 """Helper function for unary operators.
 
diff --git a/python/mxnet/numpy/multiarray.py b/python/mxnet/numpy/multiarray.py
index cafc656..83fcfc1 100644
--- a/python/mxnet/numpy/multiarray.py
+++ b/python/mxnet/numpy/multiarray.py
@@ -45,7 +45,7 @@ from ..ndarray.numpy import _internal as _npi
 
 __all__ = ['ndarray', 'empty', 'array', 'zeros', 'ones', 'maximum', 'minimum', 
'stack', 'arange',
'argmax', 'add', 'subtract', 'multiply', 'divide', 'mod', 'power', 
'concatenate',
-   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace', 
'sin', 'cos',
+   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace', 
'eye', 'sin', 'cos',
'sin', 'cos', 'sinh', 'cosh', 'log10', 'sqrt', 'abs', 'exp', 
'arctan', 'sign', 'log',
'degrees', 'log2', 'rint', 'radians', 'mean', 'reciprocal', 
'square', 'arcsin',
'argsort']
@@ -2144,6 +2144,33 @@ def linspace(start, stop, num=50, endpoint=True, 
retstep=False, dtype=None, axis
 
 
 @set_module('mxnet.numpy')
+def eye(N, M=None, k=0, dtype=_np.float32, **kwargs):
+"""
+Return a 2-D array with ones on the diagonal and zeros elsewhere.
+
+Parameters
+--
+N : int
+Number of rows in the output.
+M : int, optional
+Number of columns in the output. If None, defaults to N.
+k : int, optional
+Index of the diagonal: 0 (the default) refers to the main diagonal,
+a positive value refers to an upper diagonal,
+and a negative value to a lower diagonal.
+dtype : data-type, optional
+Data-type of the returned array.
+
+Returns
+---
+I : ndarray of shape (N,M)
+An array where all elements are equal to zero,
+except for the k-th diagonal, whose values are equal to one.
+"""
+return _mx_nd_np.eye(N, M, k, dtype, **kwargs)
+
+
+@set_module('mxnet.numpy')
 def sin(x, out=None, **kwargs):
 r"""Trigonometric sine, element-wise.
 
diff --git 

[incubator-mxnet] 39/42: numpy eye op (#15282)

2019-07-22 Thread haoj
This is an automated email from the ASF dual-hosted git repository.

haoj pushed a commit to branch numpy
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit ee0765684d8ba695fe761536cdee3a984401de80
Author: Jake Lee 
AuthorDate: Fri Jul 12 03:18:53 2019 -0700

numpy eye op (#15282)

address the comment
---
 python/mxnet/ndarray/numpy/_op.py  |  33 +-
 python/mxnet/numpy/multiarray.py   |  29 -
 python/mxnet/symbol/numpy/_symbol.py   |  33 +-
 src/operator/numpy/np_init_op.cc   |  30 -
 src/operator/numpy/np_init_op.cu   |   5 +-
 src/operator/numpy/np_init_op.h| 113 +
 src/operator/tensor/init_op.h  |  40 +++-
 tests/python/unittest/test_numpy_op.py |  69 
 8 files changed, 314 insertions(+), 38 deletions(-)

diff --git a/python/mxnet/ndarray/numpy/_op.py 
b/python/mxnet/ndarray/numpy/_op.py
index 7f710a0..ff0e8c8 100644
--- a/python/mxnet/ndarray/numpy/_op.py
+++ b/python/mxnet/ndarray/numpy/_op.py
@@ -30,7 +30,7 @@ from ..ndarray import NDArray
 
 __all__ = ['zeros', 'ones', 'maximum', 'minimum', 'stack', 'arange', 'argmax',
'add', 'subtract', 'multiply', 'divide', 'mod', 'power', 
'concatenate',
-   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace',
+   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace', 
'eye',
'sin', 'cos', 'sinh', 'cosh', 'log10', 'sqrt', 'abs', 'exp', 
'arctan', 'sign', 'log',
'degrees', 'log2', 'rint', 'radians', 'mean', 'reciprocal', 
'square', 'arcsin',
'argsort']
@@ -997,6 +997,37 @@ def linspace(start, stop, num=50, endpoint=True, 
retstep=False, dtype=None, axis
 return _npi.linspace(start=start, stop=stop, num=num, 
endpoint=endpoint, ctx=ctx, dtype=dtype)
 
 
+@set_module('mxnet.ndarray.numpy')
+def eye(N, M=None, k=0, dtype=_np.float32, **kwargs):
+"""
+Return a 2-D array with ones on the diagonal and zeros elsewhere.
+
+Parameters
+--
+N : int
+Number of rows in the output.
+M : int, optional
+Number of columns in the output. If None, defaults to N.
+k : int, optional
+Index of the diagonal: 0 (the default) refers to the main diagonal,
+a positive value refers to an upper diagonal,
+and a negative value to a lower diagonal.
+dtype : data-type, optional
+Data-type of the returned array.
+
+Returns
+---
+I : ndarray of shape (N,M)
+An array where all elements are equal to zero,
+except for the k-th diagonal, whose values are equal to one.
+"""
+_sanity_check_params('eye', ['order'], kwargs)
+ctx = kwargs.pop('ctx', current_context())
+if ctx is None:
+ctx = current_context()
+return _npi.eye(N, M, k, ctx, dtype)
+
+
 def _unary_func_helper(x, fn_array, fn_scalar, out=None, **kwargs):
 """Helper function for unary operators.
 
diff --git a/python/mxnet/numpy/multiarray.py b/python/mxnet/numpy/multiarray.py
index cafc656..83fcfc1 100644
--- a/python/mxnet/numpy/multiarray.py
+++ b/python/mxnet/numpy/multiarray.py
@@ -45,7 +45,7 @@ from ..ndarray.numpy import _internal as _npi
 
 __all__ = ['ndarray', 'empty', 'array', 'zeros', 'ones', 'maximum', 'minimum', 
'stack', 'arange',
'argmax', 'add', 'subtract', 'multiply', 'divide', 'mod', 'power', 
'concatenate',
-   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace', 
'sin', 'cos',
+   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace', 
'eye', 'sin', 'cos',
'sin', 'cos', 'sinh', 'cosh', 'log10', 'sqrt', 'abs', 'exp', 
'arctan', 'sign', 'log',
'degrees', 'log2', 'rint', 'radians', 'mean', 'reciprocal', 
'square', 'arcsin',
'argsort']
@@ -2144,6 +2144,33 @@ def linspace(start, stop, num=50, endpoint=True, 
retstep=False, dtype=None, axis
 
 
 @set_module('mxnet.numpy')
+def eye(N, M=None, k=0, dtype=_np.float32, **kwargs):
+"""
+Return a 2-D array with ones on the diagonal and zeros elsewhere.
+
+Parameters
+--
+N : int
+Number of rows in the output.
+M : int, optional
+Number of columns in the output. If None, defaults to N.
+k : int, optional
+Index of the diagonal: 0 (the default) refers to the main diagonal,
+a positive value refers to an upper diagonal,
+and a negative value to a lower diagonal.
+dtype : data-type, optional
+Data-type of the returned array.
+
+Returns
+---
+I : ndarray of shape (N,M)
+An array where all elements are equal to zero,
+except for the k-th diagonal, whose values are equal to one.
+"""
+return _mx_nd_np.eye(N, M, k, dtype, **kwargs)
+
+
+@set_module('mxnet.numpy')
 def sin(x, out=None, **kwargs):
 r"""Trigonometric sine, element-wise.
 
diff --git 

[incubator-mxnet] 39/42: numpy eye op (#15282)

2019-07-18 Thread haoj
This is an automated email from the ASF dual-hosted git repository.

haoj pushed a commit to branch numpy
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit 172c006d9edb06610207da8776a55da6121ffe42
Author: Jake Lee 
AuthorDate: Fri Jul 12 03:18:53 2019 -0700

numpy eye op (#15282)

address the comment
---
 python/mxnet/ndarray/numpy/_op.py  |  33 +-
 python/mxnet/numpy/multiarray.py   |  29 -
 python/mxnet/symbol/numpy/_symbol.py   |  33 +-
 src/operator/numpy/np_init_op.cc   |  30 -
 src/operator/numpy/np_init_op.cu   |   5 +-
 src/operator/numpy/np_init_op.h| 113 +
 src/operator/tensor/init_op.h  |  40 +++-
 tests/python/unittest/test_numpy_op.py |  69 
 8 files changed, 314 insertions(+), 38 deletions(-)

diff --git a/python/mxnet/ndarray/numpy/_op.py 
b/python/mxnet/ndarray/numpy/_op.py
index 7f710a0..ff0e8c8 100644
--- a/python/mxnet/ndarray/numpy/_op.py
+++ b/python/mxnet/ndarray/numpy/_op.py
@@ -30,7 +30,7 @@ from ..ndarray import NDArray
 
 __all__ = ['zeros', 'ones', 'maximum', 'minimum', 'stack', 'arange', 'argmax',
'add', 'subtract', 'multiply', 'divide', 'mod', 'power', 
'concatenate',
-   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace',
+   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace', 
'eye',
'sin', 'cos', 'sinh', 'cosh', 'log10', 'sqrt', 'abs', 'exp', 
'arctan', 'sign', 'log',
'degrees', 'log2', 'rint', 'radians', 'mean', 'reciprocal', 
'square', 'arcsin',
'argsort']
@@ -997,6 +997,37 @@ def linspace(start, stop, num=50, endpoint=True, 
retstep=False, dtype=None, axis
 return _npi.linspace(start=start, stop=stop, num=num, 
endpoint=endpoint, ctx=ctx, dtype=dtype)
 
 
+@set_module('mxnet.ndarray.numpy')
+def eye(N, M=None, k=0, dtype=_np.float32, **kwargs):
+"""
+Return a 2-D array with ones on the diagonal and zeros elsewhere.
+
+Parameters
+--
+N : int
+Number of rows in the output.
+M : int, optional
+Number of columns in the output. If None, defaults to N.
+k : int, optional
+Index of the diagonal: 0 (the default) refers to the main diagonal,
+a positive value refers to an upper diagonal,
+and a negative value to a lower diagonal.
+dtype : data-type, optional
+Data-type of the returned array.
+
+Returns
+---
+I : ndarray of shape (N,M)
+An array where all elements are equal to zero,
+except for the k-th diagonal, whose values are equal to one.
+"""
+_sanity_check_params('eye', ['order'], kwargs)
+ctx = kwargs.pop('ctx', current_context())
+if ctx is None:
+ctx = current_context()
+return _npi.eye(N, M, k, ctx, dtype)
+
+
 def _unary_func_helper(x, fn_array, fn_scalar, out=None, **kwargs):
 """Helper function for unary operators.
 
diff --git a/python/mxnet/numpy/multiarray.py b/python/mxnet/numpy/multiarray.py
index cafc656..83fcfc1 100644
--- a/python/mxnet/numpy/multiarray.py
+++ b/python/mxnet/numpy/multiarray.py
@@ -45,7 +45,7 @@ from ..ndarray.numpy import _internal as _npi
 
 __all__ = ['ndarray', 'empty', 'array', 'zeros', 'ones', 'maximum', 'minimum', 
'stack', 'arange',
'argmax', 'add', 'subtract', 'multiply', 'divide', 'mod', 'power', 
'concatenate',
-   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace', 
'sin', 'cos',
+   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace', 
'eye', 'sin', 'cos',
'sin', 'cos', 'sinh', 'cosh', 'log10', 'sqrt', 'abs', 'exp', 
'arctan', 'sign', 'log',
'degrees', 'log2', 'rint', 'radians', 'mean', 'reciprocal', 
'square', 'arcsin',
'argsort']
@@ -2144,6 +2144,33 @@ def linspace(start, stop, num=50, endpoint=True, 
retstep=False, dtype=None, axis
 
 
 @set_module('mxnet.numpy')
+def eye(N, M=None, k=0, dtype=_np.float32, **kwargs):
+"""
+Return a 2-D array with ones on the diagonal and zeros elsewhere.
+
+Parameters
+--
+N : int
+Number of rows in the output.
+M : int, optional
+Number of columns in the output. If None, defaults to N.
+k : int, optional
+Index of the diagonal: 0 (the default) refers to the main diagonal,
+a positive value refers to an upper diagonal,
+and a negative value to a lower diagonal.
+dtype : data-type, optional
+Data-type of the returned array.
+
+Returns
+---
+I : ndarray of shape (N,M)
+An array where all elements are equal to zero,
+except for the k-th diagonal, whose values are equal to one.
+"""
+return _mx_nd_np.eye(N, M, k, dtype, **kwargs)
+
+
+@set_module('mxnet.numpy')
 def sin(x, out=None, **kwargs):
 r"""Trigonometric sine, element-wise.
 
diff --git 

[incubator-mxnet] 39/42: numpy eye op (#15282)

2019-07-17 Thread haoj
This is an automated email from the ASF dual-hosted git repository.

haoj pushed a commit to branch numpy
in repository https://gitbox.apache.org/repos/asf/incubator-mxnet.git

commit 6c0221bed355924e230dace53da581ffbeee76cc
Author: Jake Lee 
AuthorDate: Fri Jul 12 03:18:53 2019 -0700

numpy eye op (#15282)

address the comment
---
 python/mxnet/ndarray/numpy/_op.py  |  33 +-
 python/mxnet/numpy/multiarray.py   |  29 -
 python/mxnet/symbol/numpy/_symbol.py   |  33 +-
 src/operator/numpy/np_init_op.cc   |  30 -
 src/operator/numpy/np_init_op.cu   |   5 +-
 src/operator/numpy/np_init_op.h| 113 +
 src/operator/tensor/init_op.h  |  40 +++-
 tests/python/unittest/test_numpy_op.py |  69 
 8 files changed, 314 insertions(+), 38 deletions(-)

diff --git a/python/mxnet/ndarray/numpy/_op.py 
b/python/mxnet/ndarray/numpy/_op.py
index 7f710a0..ff0e8c8 100644
--- a/python/mxnet/ndarray/numpy/_op.py
+++ b/python/mxnet/ndarray/numpy/_op.py
@@ -30,7 +30,7 @@ from ..ndarray import NDArray
 
 __all__ = ['zeros', 'ones', 'maximum', 'minimum', 'stack', 'arange', 'argmax',
'add', 'subtract', 'multiply', 'divide', 'mod', 'power', 
'concatenate',
-   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace',
+   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace', 
'eye',
'sin', 'cos', 'sinh', 'cosh', 'log10', 'sqrt', 'abs', 'exp', 
'arctan', 'sign', 'log',
'degrees', 'log2', 'rint', 'radians', 'mean', 'reciprocal', 
'square', 'arcsin',
'argsort']
@@ -997,6 +997,37 @@ def linspace(start, stop, num=50, endpoint=True, 
retstep=False, dtype=None, axis
 return _npi.linspace(start=start, stop=stop, num=num, 
endpoint=endpoint, ctx=ctx, dtype=dtype)
 
 
+@set_module('mxnet.ndarray.numpy')
+def eye(N, M=None, k=0, dtype=_np.float32, **kwargs):
+"""
+Return a 2-D array with ones on the diagonal and zeros elsewhere.
+
+Parameters
+--
+N : int
+Number of rows in the output.
+M : int, optional
+Number of columns in the output. If None, defaults to N.
+k : int, optional
+Index of the diagonal: 0 (the default) refers to the main diagonal,
+a positive value refers to an upper diagonal,
+and a negative value to a lower diagonal.
+dtype : data-type, optional
+Data-type of the returned array.
+
+Returns
+---
+I : ndarray of shape (N,M)
+An array where all elements are equal to zero,
+except for the k-th diagonal, whose values are equal to one.
+"""
+_sanity_check_params('eye', ['order'], kwargs)
+ctx = kwargs.pop('ctx', current_context())
+if ctx is None:
+ctx = current_context()
+return _npi.eye(N, M, k, ctx, dtype)
+
+
 def _unary_func_helper(x, fn_array, fn_scalar, out=None, **kwargs):
 """Helper function for unary operators.
 
diff --git a/python/mxnet/numpy/multiarray.py b/python/mxnet/numpy/multiarray.py
index cafc656..83fcfc1 100644
--- a/python/mxnet/numpy/multiarray.py
+++ b/python/mxnet/numpy/multiarray.py
@@ -45,7 +45,7 @@ from ..ndarray.numpy import _internal as _npi
 
 __all__ = ['ndarray', 'empty', 'array', 'zeros', 'ones', 'maximum', 'minimum', 
'stack', 'arange',
'argmax', 'add', 'subtract', 'multiply', 'divide', 'mod', 'power', 
'concatenate',
-   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace', 
'sin', 'cos',
+   'clip', 'split', 'swapaxes', 'expand_dims', 'tile', 'linspace', 
'eye', 'sin', 'cos',
'sin', 'cos', 'sinh', 'cosh', 'log10', 'sqrt', 'abs', 'exp', 
'arctan', 'sign', 'log',
'degrees', 'log2', 'rint', 'radians', 'mean', 'reciprocal', 
'square', 'arcsin',
'argsort']
@@ -2144,6 +2144,33 @@ def linspace(start, stop, num=50, endpoint=True, 
retstep=False, dtype=None, axis
 
 
 @set_module('mxnet.numpy')
+def eye(N, M=None, k=0, dtype=_np.float32, **kwargs):
+"""
+Return a 2-D array with ones on the diagonal and zeros elsewhere.
+
+Parameters
+--
+N : int
+Number of rows in the output.
+M : int, optional
+Number of columns in the output. If None, defaults to N.
+k : int, optional
+Index of the diagonal: 0 (the default) refers to the main diagonal,
+a positive value refers to an upper diagonal,
+and a negative value to a lower diagonal.
+dtype : data-type, optional
+Data-type of the returned array.
+
+Returns
+---
+I : ndarray of shape (N,M)
+An array where all elements are equal to zero,
+except for the k-th diagonal, whose values are equal to one.
+"""
+return _mx_nd_np.eye(N, M, k, dtype, **kwargs)
+
+
+@set_module('mxnet.numpy')
 def sin(x, out=None, **kwargs):
 r"""Trigonometric sine, element-wise.
 
diff --git