You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2020/10/09 21:05:43 UTC

[GitHub] [incubator-mxnet] Zha0q1 opened a new pull request #19324: Numpy std var large tensor fix

Zha0q1 opened a new pull request #19324:
URL: https://github.com/apache/incubator-mxnet/pull/19324


   This PR fixes std and var against large tensors


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] Zha0q1 commented on a change in pull request #19324: Numpy std var large tensor fix

Posted by GitBox <gi...@apache.org>.
Zha0q1 commented on a change in pull request #19324:
URL: https://github.com/apache/incubator-mxnet/pull/19324#discussion_r504272611



##########
File path: tests/nightly/test_np_large_array.py
##########
@@ -1875,7 +1875,6 @@ def test_cross():
     assert inp.grad[-1, 0] == 5 and inp.grad[-1, 1] == -4 and inp.grad[-1, 2] == -1
 
 
-@use_np

Review comment:
       oops, added it back

##########
File path: src/operator/nn/moments-inl.h
##########
@@ -77,7 +77,7 @@ inline bool MomentsType(const nnvm::NodeAttrs& attrs,
 
 struct VarBroadcastKernel {
   template<typename DType>
-  MSHADOW_XINLINE static void Map(int i,
+  MSHADOW_XINLINE static void Map(index_t i,
                                   DType *out,
                                   const DType *data,
                                   const DType *mean,

Review comment:
       changed




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] mxnet-bot commented on pull request #19324: Numpy std var large tensor fix

Posted by GitBox <gi...@apache.org>.
mxnet-bot commented on pull request #19324:
URL: https://github.com/apache/incubator-mxnet/pull/19324#issuecomment-706402203


   Hey @Zha0q1 , Thanks for submitting the PR 
   All tests are already queued to run once. If tests fail, you can trigger one or more tests again with the following commands: 
   - To trigger all jobs: @mxnet-bot run ci [all] 
   - To trigger specific jobs: @mxnet-bot run ci [job1, job2] 
   *** 
   **CI supported jobs**: [unix-cpu, windows-cpu, windows-gpu, sanity, centos-cpu, edge, centos-gpu, clang, unix-gpu, website, miscellaneous]
   *** 
   _Note_: 
    Only following 3 categories can trigger CI :PR Author, MXNet Committer, Jenkins Admin. 
   All CI tests must pass before the PR can be merged. 
   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] access2rohit commented on a change in pull request #19324: Numpy std var large tensor fix

Posted by GitBox <gi...@apache.org>.
access2rohit commented on a change in pull request #19324:
URL: https://github.com/apache/incubator-mxnet/pull/19324#discussion_r503754668



##########
File path: tests/nightly/test_np_large_array.py
##########
@@ -1886,3 +1885,36 @@ def test_array_split():
     assert out[0][0][0] == 0
     assert out[1][-1][-1] == 2
 
+
+@use_np
+def test_std():
+    N = 2*20
+    inp = np.zeros((2, INT_OVERFLOW))
+    inp[-1, -1] = N
+    inp.attach_grad()
+    with mx.autograd.record():
+        out = np.std(inp, axis=1)
+        out.backward()
+    assert out.shape == (2, )

Review comment:
       can we directly comapre the outputs with actual numpy's operators ? call `import numpy as _np`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] access2rohit commented on a change in pull request #19324: Numpy std var large tensor fix

Posted by GitBox <gi...@apache.org>.
access2rohit commented on a change in pull request #19324:
URL: https://github.com/apache/incubator-mxnet/pull/19324#discussion_r503753603



##########
File path: tests/nightly/test_np_large_array.py
##########
@@ -1875,7 +1875,6 @@ def test_cross():
     assert inp.grad[-1, 0] == 5 and inp.grad[-1, 1] == -4 and inp.grad[-1, 2] == -1
 
 
-@use_np

Review comment:
       why ?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] Zha0q1 commented on a change in pull request #19324: Numpy std var large tensor fix

Posted by GitBox <gi...@apache.org>.
Zha0q1 commented on a change in pull request #19324:
URL: https://github.com/apache/incubator-mxnet/pull/19324#discussion_r504269092



##########
File path: tests/nightly/test_np_large_array.py
##########
@@ -1886,3 +1885,36 @@ def test_array_split():
     assert out[0][0][0] == 0
     assert out[1][-1][-1] == 2
 
+
+@use_np
+def test_std():
+    N = 2*20
+    inp = np.zeros((2, INT_OVERFLOW))
+    inp[-1, -1] = N
+    inp.attach_grad()
+    with mx.autograd.record():
+        out = np.std(inp, axis=1)
+        out.backward()
+    assert out.shape == (2, )

Review comment:
       I tried that first but it would take too long to run on large tensors so I instead derived a analytical formula. The correctness has been verified with small tensor size first then I switched to large tenosr




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] Zha0q1 commented on pull request #19324: Numpy std var large tensor fix

Posted by GitBox <gi...@apache.org>.
Zha0q1 commented on pull request #19324:
URL: https://github.com/apache/incubator-mxnet/pull/19324#issuecomment-706803753


   @access2rohit 


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] access2rohit commented on a change in pull request #19324: Numpy std var large tensor fix

Posted by GitBox <gi...@apache.org>.
access2rohit commented on a change in pull request #19324:
URL: https://github.com/apache/incubator-mxnet/pull/19324#discussion_r503754668



##########
File path: tests/nightly/test_np_large_array.py
##########
@@ -1886,3 +1885,36 @@ def test_array_split():
     assert out[0][0][0] == 0
     assert out[1][-1][-1] == 2
 
+
+@use_np
+def test_std():
+    N = 2*20
+    inp = np.zeros((2, INT_OVERFLOW))
+    inp[-1, -1] = N
+    inp.attach_grad()
+    with mx.autograd.record():
+        out = np.std(inp, axis=1)
+        out.backward()
+    assert out.shape == (2, )

Review comment:
       can we directly comapre the outputs with actual numpy's operators ? call `import numpy as _np`
   Then we probably don't have to worry about correctness of the formula used? @Zha0q1 wdyt ?




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] access2rohit commented on a change in pull request #19324: Numpy std var large tensor fix

Posted by GitBox <gi...@apache.org>.
access2rohit commented on a change in pull request #19324:
URL: https://github.com/apache/incubator-mxnet/pull/19324#discussion_r505937314



##########
File path: tests/nightly/test_np_large_array.py
##########
@@ -1886,3 +1885,36 @@ def test_array_split():
     assert out[0][0][0] == 0
     assert out[1][-1][-1] == 2
 
+
+@use_np
+def test_std():
+    N = 2*20
+    inp = np.zeros((2, INT_OVERFLOW))
+    inp[-1, -1] = N
+    inp.attach_grad()
+    with mx.autograd.record():
+        out = np.std(inp, axis=1)
+        out.backward()
+    assert out.shape == (2, )

Review comment:
       https://www.mathsisfun.com/data/standard-deviation-formulas.html




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] sandeep-krishnamurthy merged pull request #19324: Numpy std var large tensor fix

Posted by GitBox <gi...@apache.org>.
sandeep-krishnamurthy merged pull request #19324:
URL: https://github.com/apache/incubator-mxnet/pull/19324


   


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] access2rohit commented on a change in pull request #19324: Numpy std var large tensor fix

Posted by GitBox <gi...@apache.org>.
access2rohit commented on a change in pull request #19324:
URL: https://github.com/apache/incubator-mxnet/pull/19324#discussion_r503753173



##########
File path: src/operator/nn/moments-inl.h
##########
@@ -77,7 +77,7 @@ inline bool MomentsType(const nnvm::NodeAttrs& attrs,
 
 struct VarBroadcastKernel {
   template<typename DType>
-  MSHADOW_XINLINE static void Map(int i,
+  MSHADOW_XINLINE static void Map(index_t i,
                                   DType *out,
                                   const DType *data,
                                   const DType *mean,

Review comment:
       can you change index variables inside the kernels to `index_t` from `size_t`

##########
File path: src/operator/nn/moments-inl.h
##########
@@ -77,7 +77,7 @@ inline bool MomentsType(const nnvm::NodeAttrs& attrs,
 
 struct VarBroadcastKernel {
   template<typename DType>
-  MSHADOW_XINLINE static void Map(int i,
+  MSHADOW_XINLINE static void Map(index_t i,
                                   DType *out,
                                   const DType *data,
                                   const DType *mean,

Review comment:
       can you change index variables inside the kernel to `index_t` from `size_t`




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [incubator-mxnet] Zha0q1 commented on pull request #19324: Numpy std var large tensor fix

Posted by GitBox <gi...@apache.org>.
Zha0q1 commented on pull request #19324:
URL: https://github.com/apache/incubator-mxnet/pull/19324#issuecomment-706611136


   local run:
   
   ```
   ubuntu@ip-172-31-38-169:~/incubator-mxnet/build$ pytest ../tests/nightly/test_np_large_array.py::test_std
   /home/ubuntu/anaconda3/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject
     return f(*args, **kwds)
   /home/ubuntu/anaconda3/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject
     return f(*args, **kwds)
   /home/ubuntu/anaconda3/lib/python3.7/importlib/_bootstrap.py:219: RuntimeWarning: numpy.ufunc size changed, may indicate binary incompatibility. Expected 192 from C header, got 216 from PyObject
     return f(*args, **kwds)
   ================================================ test session starts ================================================
   platform linux -- Python 3.7.7, pytest-5.4.1, py-1.8.1, pluggy-0.13.1
   rootdir: /home/ubuntu/incubator-mxnet, inifile: pytest.ini
   plugins: remotedata-0.3.2, openfiles-0.4.0, astropy-header-0.1.2, hypothesis-5.8.3, arraydiff-0.3, doctestplus-0.5.0
   collected 1 item                                                                                                    
   
   ../tests/nightly/test_np_large_array.py                               .                                                                     [100%]
   
   =========================================== 1 passed in 284.49s (0:04:44) ==========================================
   ```


----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org