[incubator-mxnet] 28/42: [numpy] Misc fix for other chapters (#15332)
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 0565405699403698573224b4d8fc01700cae87e5 Author: reminisce AuthorDate: Sun Jun 23 14:16:31 2019 -0700 [numpy] Misc fix for other chapters (#15332) * Add np.prod * Fix ndarray.reshape accepting positional integers as arguments * Rebase * Fix rebase error * Add np.ndarray.flatten * Fix * Add broadcast_to * Add meshgrid and broadcast_arrays * Fix sin, cos, sinh, cosh not supporting scalars * Add more unary ops supporting python scalars * Fix * Fix * Fix ci * Fix sanity --- python/mxnet/_numpy_op_doc.py | 34 +++ python/mxnet/gluon/block.py| 13 +- python/mxnet/gluon/data/vision/datasets.py | 2 + python/mxnet/ndarray/ndarray.py| 2 +- python/mxnet/ndarray/numpy/_op.py | 220 +++-- python/mxnet/ndarray/register.py | 20 +- python/mxnet/numpy/__init__.py | 8 +- python/mxnet/numpy/function_base.py| 115 + .../{numpy_extension/__init__.py => numpy/io.py} | 36 ++- python/mxnet/numpy/multiarray.py | 275 + python/mxnet/numpy/stride_tricks.py| 56 + python/mxnet/numpy/utils.py| 107 +--- python/mxnet/numpy_extension/__init__.py | 1 + python/mxnet/{numpy => numpy_extension}/utils.py | 2 +- python/mxnet/symbol/numpy/_symbol.py | 240 -- python/mxnet/symbol/numpy/linalg.py| 5 +- python/mxnet/symbol/register.py| 8 +- src/operator/numpy/np_broadcast_reduce_op.h| 67 - src/operator/numpy/np_broadcast_reduce_op_value.cc | 75 +- src/operator/numpy/np_broadcast_reduce_op_value.cu | 12 + src/operator/numpy/np_elemwise_unary_op_basic.cc | 12 +- src/operator/numpy/np_elemwise_unary_op_basic.cu | 12 +- src/operator/tensor/broadcast_reduce_op.h | 36 +-- tests/python/unittest/test_numpy_ndarray.py| 10 +- tests/python/unittest/test_numpy_op.py | 104 +++- 25 files changed, 1210 insertions(+), 262 deletions(-) diff --git a/python/mxnet/_numpy_op_doc.py b/python/mxnet/_numpy_op_doc.py index ab81732..995a65c 100644 --- a/python/mxnet/_numpy_op_doc.py +++ b/python/mxnet/_numpy_op_doc.py @@ -139,3 +139,37 @@ def _npi_multinomial(a): In other words, each entry ``out[i,j,...,:]`` is an N-dimensional value drawn from the distribution. """ pass + + +def _np_cumsum(a, axis=None, dtype=None, out=None): +""" +Return the cumulative sum of the elements along a given axis. + +Parameters +-- +a : array_like +Input array. +axis : int, optional +Axis along which the cumulative sum is computed. The default +(None) is to compute the cumsum over the flattened array. +dtype : dtype, optional +Type of the returned array and of the accumulator in which the +elements are summed. If `dtype` is not specified, it defaults +to the dtype of `a`, unless `a` has an integer dtype with a +precision less than that of the default platform integer. In +that case, the default platform integer is used. +out : ndarray, optional +Alternative output array in which to place the result. It must +have the same shape and buffer length as the expected output +but the type will be cast if necessary. See `doc.ufuncs` +(Section "Output arguments") for more details. + +Returns +--- +cumsum_along_axis : ndarray. +A new array holding the result is returned unless `out` is +specified, in which case a reference to `out` is returned. The +result has the same size as `a`, and the same shape as `a` if +`axis` is not None or `a` is a 1-d array. +""" +pass diff --git a/python/mxnet/gluon/block.py b/python/mxnet/gluon/block.py index 7866cfb..5b8b2e8 100644 --- a/python/mxnet/gluon/block.py +++ b/python/mxnet/gluon/block.py @@ -36,7 +36,7 @@ from .parameter import Parameter, ParameterDict, DeferredInitializationError from .utils import _indent, _brief_print_list, HookHandle from .utils import _check_same_symbol_type, _check_all_np_ndarrays from .. import numpy_extension as _mx_npx -from .. import numpy as _mx_np +from .. import numpy as _mx_np, numpy_extension as _mx_npx from .. util import is_np_array @@ -336,10 +336,8 @@ class Block(object): """ params = self._collect_params_with_prefix() arg_dict = {key : val._reduce() for key, val in params.items()} -if is_np_array(): -_mx_np.save(filename,
[incubator-mxnet] 28/42: [numpy] Misc fix for other chapters (#15332)
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 0a15f7e57c043b3e57a7930edbbe84f7019df05a Author: reminisce AuthorDate: Sun Jun 23 14:16:31 2019 -0700 [numpy] Misc fix for other chapters (#15332) * Add np.prod * Fix ndarray.reshape accepting positional integers as arguments * Rebase * Fix rebase error * Add np.ndarray.flatten * Fix * Add broadcast_to * Add meshgrid and broadcast_arrays * Fix sin, cos, sinh, cosh not supporting scalars * Add more unary ops supporting python scalars * Fix * Fix * Fix ci * Fix sanity --- python/mxnet/_numpy_op_doc.py | 34 +++ python/mxnet/gluon/block.py| 13 +- python/mxnet/gluon/data/vision/datasets.py | 2 + python/mxnet/ndarray/ndarray.py| 2 +- python/mxnet/ndarray/numpy/_op.py | 220 +++-- python/mxnet/ndarray/register.py | 20 +- python/mxnet/numpy/__init__.py | 8 +- python/mxnet/numpy/function_base.py| 115 + .../{numpy_extension/__init__.py => numpy/io.py} | 36 ++- python/mxnet/numpy/multiarray.py | 275 + python/mxnet/numpy/stride_tricks.py| 56 + python/mxnet/numpy/utils.py| 107 +--- python/mxnet/numpy_extension/__init__.py | 1 + python/mxnet/{numpy => numpy_extension}/utils.py | 2 +- python/mxnet/symbol/numpy/_symbol.py | 240 -- python/mxnet/symbol/numpy/linalg.py| 5 +- python/mxnet/symbol/register.py| 8 +- src/operator/numpy/np_broadcast_reduce_op.h| 67 - src/operator/numpy/np_broadcast_reduce_op_value.cc | 75 +- src/operator/numpy/np_broadcast_reduce_op_value.cu | 12 + src/operator/numpy/np_elemwise_unary_op_basic.cc | 12 +- src/operator/numpy/np_elemwise_unary_op_basic.cu | 12 +- src/operator/tensor/broadcast_reduce_op.h | 36 +-- tests/python/unittest/test_numpy_ndarray.py| 10 +- tests/python/unittest/test_numpy_op.py | 104 +++- 25 files changed, 1210 insertions(+), 262 deletions(-) diff --git a/python/mxnet/_numpy_op_doc.py b/python/mxnet/_numpy_op_doc.py index ab81732..995a65c 100644 --- a/python/mxnet/_numpy_op_doc.py +++ b/python/mxnet/_numpy_op_doc.py @@ -139,3 +139,37 @@ def _npi_multinomial(a): In other words, each entry ``out[i,j,...,:]`` is an N-dimensional value drawn from the distribution. """ pass + + +def _np_cumsum(a, axis=None, dtype=None, out=None): +""" +Return the cumulative sum of the elements along a given axis. + +Parameters +-- +a : array_like +Input array. +axis : int, optional +Axis along which the cumulative sum is computed. The default +(None) is to compute the cumsum over the flattened array. +dtype : dtype, optional +Type of the returned array and of the accumulator in which the +elements are summed. If `dtype` is not specified, it defaults +to the dtype of `a`, unless `a` has an integer dtype with a +precision less than that of the default platform integer. In +that case, the default platform integer is used. +out : ndarray, optional +Alternative output array in which to place the result. It must +have the same shape and buffer length as the expected output +but the type will be cast if necessary. See `doc.ufuncs` +(Section "Output arguments") for more details. + +Returns +--- +cumsum_along_axis : ndarray. +A new array holding the result is returned unless `out` is +specified, in which case a reference to `out` is returned. The +result has the same size as `a`, and the same shape as `a` if +`axis` is not None or `a` is a 1-d array. +""" +pass diff --git a/python/mxnet/gluon/block.py b/python/mxnet/gluon/block.py index 7866cfb..5b8b2e8 100644 --- a/python/mxnet/gluon/block.py +++ b/python/mxnet/gluon/block.py @@ -36,7 +36,7 @@ from .parameter import Parameter, ParameterDict, DeferredInitializationError from .utils import _indent, _brief_print_list, HookHandle from .utils import _check_same_symbol_type, _check_all_np_ndarrays from .. import numpy_extension as _mx_npx -from .. import numpy as _mx_np +from .. import numpy as _mx_np, numpy_extension as _mx_npx from .. util import is_np_array @@ -336,10 +336,8 @@ class Block(object): """ params = self._collect_params_with_prefix() arg_dict = {key : val._reduce() for key, val in params.items()} -if is_np_array(): -_mx_np.save(filename,
[incubator-mxnet] 28/42: [numpy] Misc fix for other chapters (#15332)
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 ebda0b27da0a8d8bded0aa4157a54eeae45415f1 Author: reminisce AuthorDate: Sun Jun 23 14:16:31 2019 -0700 [numpy] Misc fix for other chapters (#15332) * Add np.prod * Fix ndarray.reshape accepting positional integers as arguments * Rebase * Fix rebase error * Add np.ndarray.flatten * Fix * Add broadcast_to * Add meshgrid and broadcast_arrays * Fix sin, cos, sinh, cosh not supporting scalars * Add more unary ops supporting python scalars * Fix * Fix * Fix ci * Fix sanity --- python/mxnet/_numpy_op_doc.py | 34 +++ python/mxnet/gluon/block.py| 13 +- python/mxnet/gluon/data/vision/datasets.py | 2 + python/mxnet/ndarray/ndarray.py| 2 +- python/mxnet/ndarray/numpy/_op.py | 220 +++-- python/mxnet/ndarray/register.py | 20 +- python/mxnet/numpy/__init__.py | 8 +- python/mxnet/numpy/function_base.py| 115 + .../{numpy_extension/__init__.py => numpy/io.py} | 36 ++- python/mxnet/numpy/multiarray.py | 275 + python/mxnet/numpy/stride_tricks.py| 56 + python/mxnet/numpy/utils.py| 107 +--- python/mxnet/numpy_extension/__init__.py | 1 + python/mxnet/{numpy => numpy_extension}/utils.py | 2 +- python/mxnet/symbol/numpy/_symbol.py | 240 -- python/mxnet/symbol/numpy/linalg.py| 5 +- python/mxnet/symbol/register.py| 8 +- src/operator/numpy/np_broadcast_reduce_op.h| 67 - src/operator/numpy/np_broadcast_reduce_op_value.cc | 75 +- src/operator/numpy/np_broadcast_reduce_op_value.cu | 12 + src/operator/numpy/np_elemwise_unary_op_basic.cc | 12 +- src/operator/numpy/np_elemwise_unary_op_basic.cu | 12 +- src/operator/tensor/broadcast_reduce_op.h | 36 +-- tests/python/unittest/test_numpy_ndarray.py| 10 +- tests/python/unittest/test_numpy_op.py | 104 +++- 25 files changed, 1210 insertions(+), 262 deletions(-) diff --git a/python/mxnet/_numpy_op_doc.py b/python/mxnet/_numpy_op_doc.py index ab81732..995a65c 100644 --- a/python/mxnet/_numpy_op_doc.py +++ b/python/mxnet/_numpy_op_doc.py @@ -139,3 +139,37 @@ def _npi_multinomial(a): In other words, each entry ``out[i,j,...,:]`` is an N-dimensional value drawn from the distribution. """ pass + + +def _np_cumsum(a, axis=None, dtype=None, out=None): +""" +Return the cumulative sum of the elements along a given axis. + +Parameters +-- +a : array_like +Input array. +axis : int, optional +Axis along which the cumulative sum is computed. The default +(None) is to compute the cumsum over the flattened array. +dtype : dtype, optional +Type of the returned array and of the accumulator in which the +elements are summed. If `dtype` is not specified, it defaults +to the dtype of `a`, unless `a` has an integer dtype with a +precision less than that of the default platform integer. In +that case, the default platform integer is used. +out : ndarray, optional +Alternative output array in which to place the result. It must +have the same shape and buffer length as the expected output +but the type will be cast if necessary. See `doc.ufuncs` +(Section "Output arguments") for more details. + +Returns +--- +cumsum_along_axis : ndarray. +A new array holding the result is returned unless `out` is +specified, in which case a reference to `out` is returned. The +result has the same size as `a`, and the same shape as `a` if +`axis` is not None or `a` is a 1-d array. +""" +pass diff --git a/python/mxnet/gluon/block.py b/python/mxnet/gluon/block.py index 7866cfb..5b8b2e8 100644 --- a/python/mxnet/gluon/block.py +++ b/python/mxnet/gluon/block.py @@ -36,7 +36,7 @@ from .parameter import Parameter, ParameterDict, DeferredInitializationError from .utils import _indent, _brief_print_list, HookHandle from .utils import _check_same_symbol_type, _check_all_np_ndarrays from .. import numpy_extension as _mx_npx -from .. import numpy as _mx_np +from .. import numpy as _mx_np, numpy_extension as _mx_npx from .. util import is_np_array @@ -336,10 +336,8 @@ class Block(object): """ params = self._collect_params_with_prefix() arg_dict = {key : val._reduce() for key, val in params.items()} -if is_np_array(): -_mx_np.save(filename,
[incubator-mxnet] 28/42: [numpy] Misc fix for other chapters (#15332)
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 505e86af2f8b0f3bc6b41fcbbdb3f5e5ddd26c8d Author: reminisce AuthorDate: Sun Jun 23 14:16:31 2019 -0700 [numpy] Misc fix for other chapters (#15332) * Add np.prod * Fix ndarray.reshape accepting positional integers as arguments * Rebase * Fix rebase error * Add np.ndarray.flatten * Fix * Add broadcast_to * Add meshgrid and broadcast_arrays * Fix sin, cos, sinh, cosh not supporting scalars * Add more unary ops supporting python scalars * Fix * Fix * Fix ci * Fix sanity --- python/mxnet/_numpy_op_doc.py | 34 +++ python/mxnet/gluon/block.py| 13 +- python/mxnet/gluon/data/vision/datasets.py | 2 + python/mxnet/ndarray/ndarray.py| 2 +- python/mxnet/ndarray/numpy/_op.py | 220 +++-- python/mxnet/ndarray/register.py | 20 +- python/mxnet/numpy/__init__.py | 8 +- python/mxnet/numpy/function_base.py| 115 + .../{numpy_extension/__init__.py => numpy/io.py} | 36 ++- python/mxnet/numpy/multiarray.py | 275 + python/mxnet/numpy/stride_tricks.py| 56 + python/mxnet/numpy/utils.py| 107 +--- python/mxnet/numpy_extension/__init__.py | 1 + python/mxnet/{numpy => numpy_extension}/utils.py | 2 +- python/mxnet/symbol/numpy/_symbol.py | 240 -- python/mxnet/symbol/numpy/linalg.py| 5 +- python/mxnet/symbol/register.py| 8 +- src/operator/numpy/np_broadcast_reduce_op.h| 67 - src/operator/numpy/np_broadcast_reduce_op_value.cc | 75 +- src/operator/numpy/np_broadcast_reduce_op_value.cu | 12 + src/operator/numpy/np_elemwise_unary_op_basic.cc | 12 +- src/operator/numpy/np_elemwise_unary_op_basic.cu | 12 +- src/operator/tensor/broadcast_reduce_op.h | 36 +-- tests/python/unittest/test_numpy_ndarray.py| 10 +- tests/python/unittest/test_numpy_op.py | 104 +++- 25 files changed, 1210 insertions(+), 262 deletions(-) diff --git a/python/mxnet/_numpy_op_doc.py b/python/mxnet/_numpy_op_doc.py index ab81732..995a65c 100644 --- a/python/mxnet/_numpy_op_doc.py +++ b/python/mxnet/_numpy_op_doc.py @@ -139,3 +139,37 @@ def _npi_multinomial(a): In other words, each entry ``out[i,j,...,:]`` is an N-dimensional value drawn from the distribution. """ pass + + +def _np_cumsum(a, axis=None, dtype=None, out=None): +""" +Return the cumulative sum of the elements along a given axis. + +Parameters +-- +a : array_like +Input array. +axis : int, optional +Axis along which the cumulative sum is computed. The default +(None) is to compute the cumsum over the flattened array. +dtype : dtype, optional +Type of the returned array and of the accumulator in which the +elements are summed. If `dtype` is not specified, it defaults +to the dtype of `a`, unless `a` has an integer dtype with a +precision less than that of the default platform integer. In +that case, the default platform integer is used. +out : ndarray, optional +Alternative output array in which to place the result. It must +have the same shape and buffer length as the expected output +but the type will be cast if necessary. See `doc.ufuncs` +(Section "Output arguments") for more details. + +Returns +--- +cumsum_along_axis : ndarray. +A new array holding the result is returned unless `out` is +specified, in which case a reference to `out` is returned. The +result has the same size as `a`, and the same shape as `a` if +`axis` is not None or `a` is a 1-d array. +""" +pass diff --git a/python/mxnet/gluon/block.py b/python/mxnet/gluon/block.py index 9f5b585..09a2e2a 100644 --- a/python/mxnet/gluon/block.py +++ b/python/mxnet/gluon/block.py @@ -36,7 +36,7 @@ from .parameter import Parameter, ParameterDict, DeferredInitializationError from .utils import _indent, _brief_print_list, HookHandle from .utils import _check_same_symbol_type, _check_all_np_ndarrays from .. import numpy_extension as _mx_npx -from .. import numpy as _mx_np +from .. import numpy as _mx_np, numpy_extension as _mx_npx from .. util import is_np_array @@ -336,10 +336,8 @@ class Block(object): """ params = self._collect_params_with_prefix() arg_dict = {key : val._reduce() for key, val in params.items()} -if is_np_array(): -_mx_np.save(filename,
[incubator-mxnet] 28/42: [numpy] Misc fix for other chapters (#15332)
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 ec4fc14dda355f2e4df7e0f9526aafaa1db2072c Author: reminisce AuthorDate: Sun Jun 23 14:16:31 2019 -0700 [numpy] Misc fix for other chapters (#15332) * Add np.prod * Fix ndarray.reshape accepting positional integers as arguments * Rebase * Fix rebase error * Add np.ndarray.flatten * Fix * Add broadcast_to * Add meshgrid and broadcast_arrays * Fix sin, cos, sinh, cosh not supporting scalars * Add more unary ops supporting python scalars * Fix * Fix * Fix ci * Fix sanity --- python/mxnet/_numpy_op_doc.py | 34 +++ python/mxnet/gluon/block.py| 13 +- python/mxnet/gluon/data/vision/datasets.py | 2 + python/mxnet/ndarray/ndarray.py| 2 +- python/mxnet/ndarray/numpy/_op.py | 220 +++-- python/mxnet/ndarray/register.py | 20 +- python/mxnet/numpy/__init__.py | 8 +- python/mxnet/numpy/function_base.py| 115 + .../{numpy_extension/__init__.py => numpy/io.py} | 36 ++- python/mxnet/numpy/multiarray.py | 275 + python/mxnet/numpy/stride_tricks.py| 56 + python/mxnet/numpy/utils.py| 107 +--- python/mxnet/numpy_extension/__init__.py | 1 + python/mxnet/{numpy => numpy_extension}/utils.py | 2 +- python/mxnet/symbol/numpy/_symbol.py | 240 -- python/mxnet/symbol/numpy/linalg.py| 5 +- python/mxnet/symbol/register.py| 8 +- src/operator/numpy/np_broadcast_reduce_op.h| 67 - src/operator/numpy/np_broadcast_reduce_op_value.cc | 75 +- src/operator/numpy/np_broadcast_reduce_op_value.cu | 12 + src/operator/numpy/np_elemwise_unary_op_basic.cc | 12 +- src/operator/numpy/np_elemwise_unary_op_basic.cu | 12 +- src/operator/tensor/broadcast_reduce_op.h | 36 +-- tests/python/unittest/test_numpy_ndarray.py| 10 +- tests/python/unittest/test_numpy_op.py | 104 +++- 25 files changed, 1210 insertions(+), 262 deletions(-) diff --git a/python/mxnet/_numpy_op_doc.py b/python/mxnet/_numpy_op_doc.py index ab81732..995a65c 100644 --- a/python/mxnet/_numpy_op_doc.py +++ b/python/mxnet/_numpy_op_doc.py @@ -139,3 +139,37 @@ def _npi_multinomial(a): In other words, each entry ``out[i,j,...,:]`` is an N-dimensional value drawn from the distribution. """ pass + + +def _np_cumsum(a, axis=None, dtype=None, out=None): +""" +Return the cumulative sum of the elements along a given axis. + +Parameters +-- +a : array_like +Input array. +axis : int, optional +Axis along which the cumulative sum is computed. The default +(None) is to compute the cumsum over the flattened array. +dtype : dtype, optional +Type of the returned array and of the accumulator in which the +elements are summed. If `dtype` is not specified, it defaults +to the dtype of `a`, unless `a` has an integer dtype with a +precision less than that of the default platform integer. In +that case, the default platform integer is used. +out : ndarray, optional +Alternative output array in which to place the result. It must +have the same shape and buffer length as the expected output +but the type will be cast if necessary. See `doc.ufuncs` +(Section "Output arguments") for more details. + +Returns +--- +cumsum_along_axis : ndarray. +A new array holding the result is returned unless `out` is +specified, in which case a reference to `out` is returned. The +result has the same size as `a`, and the same shape as `a` if +`axis` is not None or `a` is a 1-d array. +""" +pass diff --git a/python/mxnet/gluon/block.py b/python/mxnet/gluon/block.py index 9f5b585..09a2e2a 100644 --- a/python/mxnet/gluon/block.py +++ b/python/mxnet/gluon/block.py @@ -36,7 +36,7 @@ from .parameter import Parameter, ParameterDict, DeferredInitializationError from .utils import _indent, _brief_print_list, HookHandle from .utils import _check_same_symbol_type, _check_all_np_ndarrays from .. import numpy_extension as _mx_npx -from .. import numpy as _mx_np +from .. import numpy as _mx_np, numpy_extension as _mx_npx from .. util import is_np_array @@ -336,10 +336,8 @@ class Block(object): """ params = self._collect_params_with_prefix() arg_dict = {key : val._reduce() for key, val in params.items()} -if is_np_array(): -_mx_np.save(filename,