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/12 22:53:20 UTC

[GitHub] [incubator-mxnet] access2rohit opened a new pull request #19340: [WIP] Enable large tensor support for insert

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


   ## Description ##
   Enable LTS for numpy insert op for all there kernels(insert_scalar, insert_slice, insert_tensor). 
   
   ## Checklist ##
   ### Essentials ###
   - [ ] PR's title starts with a category (e.g. [BUGFIX], [MODEL], [TUTORIAL], [FEATURE], [DOC], etc)
   - [ ] Changes are complete (i.e. I finished coding on this PR)
   - [ ] All changes have test coverage
   - [x] Code is well-documented
   
   ### Testing ###
   Will update
   


----------------------------------------------------------------
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 #19340: [FEATURE] Enable large tensor support for insert

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



##########
File path: tests/nightly/test_np_large_array.py
##########
@@ -2035,6 +2035,7 @@ def test_vstack():
 
 
 @use_np
+<<<<<<< HEAD

Review comment:
       aahh .. missed it ! 




----------------------------------------------------------------
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 #19340: [FEATURE] Enable large tensor support for insert

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



##########
File path: tests/python/unittest/test_numpy_op.py
##########
@@ -3697,7 +3697,7 @@ def GetNdim(tp):
             np_out = _np.insert(a.asnumpy(), obj_onp, b.asnumpy(), axis=axis)
 
             assert_almost_equal(mx_out.asnumpy(), np_out, rtol=1e-3, atol=1e-5)
-
+test_np_insert()

Review comment:
       Why do we need to call it manually?




----------------------------------------------------------------
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 #19340: [FEATURE] Enable large tensor support for insert

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



##########
File path: src/operator/numpy/np_insert_op_slice-inl.h
##########
@@ -147,10 +147,11 @@ void NumpyInsertSliceCompute(const nnvm::NodeAttrs& attrs,
   } else {
     // broadcast check
     for (int i = outshape.ndim() - 1; i >= 0; --i) {
-      int sz = outshape[i];
+      index_t sz = outshape[i];
       if (i == axis) {
         sz = numnew;
       }
+      LOG(INFO) << "values.shape_[" << i << "]=" << values.shape_[i] << ", sz= " << sz;

Review comment:
       we can probably remove this now?

##########
File path: src/operator/numpy/np_insert_op_tensor-inl.h
##########
@@ -175,34 +175,34 @@ void NumpyInsertTensorCompute(const nnvm::NodeAttrs& attrs,
   } else {
     // broadcast check
     for (int i = outshape.ndim() - 1; i >= 0; --i) {
-      int sz = outshape[i];
+      size_t sz = outshape[i];
       if (i == axis) {
         sz = numnew;
       }
       CHECK((values.shape_[i] == 1) || (values.shape_[i] == sz));
     }
     size_t temp_storage_bytes, temp_mem_size;
-    temp_storage_bytes = SortByKeyWorkspaceSize<int64_t, int, xpu>(indices_len, false, true);
+    temp_storage_bytes = SortByKeyWorkspaceSize<int64_t, index_t, xpu>(indices_len, false, true);
     temp_mem_size = indices_len * sizeof(int64_t) * 2 +
-                    indices_len * sizeof(int) +
-                    outshape[axis] * sizeof(int) * 2 +
+                    indices_len * sizeof(index_t) +
+                    outshape[axis] * sizeof(index_t) * 2 +
                     temp_storage_bytes;
     Tensor<xpu, 1, char> temp_mem =
       ctx.requested[0].get_space_typed<xpu, 1, char>(Shape1(temp_mem_size), s);
     int64_t* indices_ptr = reinterpret_cast<int64_t*>(temp_mem.dptr_);
     int64_t* sorted_indices_ptr = reinterpret_cast<int64_t*>(indices_ptr + indices_len);
-    int* order_ptr = reinterpret_cast<int*>(sorted_indices_ptr + indices_len);
-    int* is_insert = reinterpret_cast<int*>(order_ptr + indices_len);
-    int* origin_idx = reinterpret_cast<int*>(is_insert + outshape[axis]);
+    index_t* order_ptr = reinterpret_cast<index_t*>(sorted_indices_ptr + indices_len);
+    index_t* is_insert = reinterpret_cast<index_t*>(order_ptr + indices_len);
+    index_t* origin_idx = reinterpret_cast<index_t*>(is_insert + outshape[axis]);

Review comment:
       would you explain a bit why this pointer conversion would work? `sorted_indices_ptr` is defined as `int64_t*` and if the pointers here are int* then the stride is different?




----------------------------------------------------------------
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 #19340: [FEATURE] Enable large tensor support for insert

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



##########
File path: src/operator/numpy/np_insert_op_tensor-inl.h
##########
@@ -175,34 +175,34 @@ void NumpyInsertTensorCompute(const nnvm::NodeAttrs& attrs,
   } else {
     // broadcast check
     for (int i = outshape.ndim() - 1; i >= 0; --i) {
-      int sz = outshape[i];
+      size_t sz = outshape[i];
       if (i == axis) {
         sz = numnew;
       }
       CHECK((values.shape_[i] == 1) || (values.shape_[i] == sz));
     }
     size_t temp_storage_bytes, temp_mem_size;
-    temp_storage_bytes = SortByKeyWorkspaceSize<int64_t, int, xpu>(indices_len, false, true);
+    temp_storage_bytes = SortByKeyWorkspaceSize<int64_t, index_t, xpu>(indices_len, false, true);
     temp_mem_size = indices_len * sizeof(int64_t) * 2 +
-                    indices_len * sizeof(int) +
-                    outshape[axis] * sizeof(int) * 2 +
+                    indices_len * sizeof(index_t) +
+                    outshape[axis] * sizeof(index_t) * 2 +
                     temp_storage_bytes;
     Tensor<xpu, 1, char> temp_mem =
       ctx.requested[0].get_space_typed<xpu, 1, char>(Shape1(temp_mem_size), s);
     int64_t* indices_ptr = reinterpret_cast<int64_t*>(temp_mem.dptr_);
     int64_t* sorted_indices_ptr = reinterpret_cast<int64_t*>(indices_ptr + indices_len);
-    int* order_ptr = reinterpret_cast<int*>(sorted_indices_ptr + indices_len);
-    int* is_insert = reinterpret_cast<int*>(order_ptr + indices_len);
-    int* origin_idx = reinterpret_cast<int*>(is_insert + outshape[axis]);
+    index_t* order_ptr = reinterpret_cast<index_t*>(sorted_indices_ptr + indices_len);
+    index_t* is_insert = reinterpret_cast<index_t*>(order_ptr + indices_len);
+    index_t* origin_idx = reinterpret_cast<index_t*>(is_insert + outshape[axis]);

Review comment:
       this is how you allocate temporary workspace(with different data types). order_ptr was `int*` before now i have changed it to `index_t*` and updated memory to be allocated for the order_ptr as well to `index_t`. Stride is for pointer index and not for data. 




----------------------------------------------------------------
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 pull request #19340: [FEATURE] Enable large tensor support for insert

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


   @mxnet-label-bot update [pr-awaiting-review]


----------------------------------------------------------------
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 pull request #19340: [FEATURE] Enable large tensor support for insert

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


   @Zha0q1 i had to fix funxtions in delete since they were used by insert. I have fixed insert_tensor as well but i needs to be optimized to be even able to test it properly. For input sizes over 10million it takes forever even w/ int32 indexing.


----------------------------------------------------------------
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 #19340: [FEATURE] Enable large tensor support for insert

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


   Left 1 comment, rest looks good!


----------------------------------------------------------------
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 #19340: [WIP] Enable large tensor support for insert

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


   Hey @access2rohit , 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**: [centos-cpu, clang, unix-gpu, sanity, windows-cpu, windows-gpu, miscellaneous, edge, website, centos-gpu, unix-cpu]
   *** 
   _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 #19340: [FEATURE] Enable large tensor support for insert

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



##########
File path: src/operator/numpy/np_insert_op_tensor-inl.h
##########
@@ -175,34 +175,34 @@ void NumpyInsertTensorCompute(const nnvm::NodeAttrs& attrs,
   } else {
     // broadcast check
     for (int i = outshape.ndim() - 1; i >= 0; --i) {
-      int sz = outshape[i];
+      size_t sz = outshape[i];
       if (i == axis) {
         sz = numnew;
       }
       CHECK((values.shape_[i] == 1) || (values.shape_[i] == sz));
     }
     size_t temp_storage_bytes, temp_mem_size;
-    temp_storage_bytes = SortByKeyWorkspaceSize<int64_t, int, xpu>(indices_len, false, true);
+    temp_storage_bytes = SortByKeyWorkspaceSize<int64_t, index_t, xpu>(indices_len, false, true);
     temp_mem_size = indices_len * sizeof(int64_t) * 2 +
-                    indices_len * sizeof(int) +
-                    outshape[axis] * sizeof(int) * 2 +
+                    indices_len * sizeof(index_t) +
+                    outshape[axis] * sizeof(index_t) * 2 +
                     temp_storage_bytes;
     Tensor<xpu, 1, char> temp_mem =
       ctx.requested[0].get_space_typed<xpu, 1, char>(Shape1(temp_mem_size), s);
     int64_t* indices_ptr = reinterpret_cast<int64_t*>(temp_mem.dptr_);
     int64_t* sorted_indices_ptr = reinterpret_cast<int64_t*>(indices_ptr + indices_len);
-    int* order_ptr = reinterpret_cast<int*>(sorted_indices_ptr + indices_len);
-    int* is_insert = reinterpret_cast<int*>(order_ptr + indices_len);
-    int* origin_idx = reinterpret_cast<int*>(is_insert + outshape[axis]);
+    index_t* order_ptr = reinterpret_cast<index_t*>(sorted_indices_ptr + indices_len);
+    index_t* is_insert = reinterpret_cast<index_t*>(order_ptr + indices_len);
+    index_t* origin_idx = reinterpret_cast<index_t*>(is_insert + outshape[axis]);

Review comment:
       correct




----------------------------------------------------------------
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 #19340: [FEATURE] Enable large tensor support for insert

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



##########
File path: src/operator/numpy/np_insert_op_tensor-inl.h
##########
@@ -175,34 +175,34 @@ void NumpyInsertTensorCompute(const nnvm::NodeAttrs& attrs,
   } else {
     // broadcast check
     for (int i = outshape.ndim() - 1; i >= 0; --i) {
-      int sz = outshape[i];
+      size_t sz = outshape[i];
       if (i == axis) {
         sz = numnew;
       }
       CHECK((values.shape_[i] == 1) || (values.shape_[i] == sz));
     }
     size_t temp_storage_bytes, temp_mem_size;
-    temp_storage_bytes = SortByKeyWorkspaceSize<int64_t, int, xpu>(indices_len, false, true);
+    temp_storage_bytes = SortByKeyWorkspaceSize<int64_t, index_t, xpu>(indices_len, false, true);
     temp_mem_size = indices_len * sizeof(int64_t) * 2 +
-                    indices_len * sizeof(int) +
-                    outshape[axis] * sizeof(int) * 2 +
+                    indices_len * sizeof(index_t) +
+                    outshape[axis] * sizeof(index_t) * 2 +
                     temp_storage_bytes;
     Tensor<xpu, 1, char> temp_mem =
       ctx.requested[0].get_space_typed<xpu, 1, char>(Shape1(temp_mem_size), s);
     int64_t* indices_ptr = reinterpret_cast<int64_t*>(temp_mem.dptr_);
     int64_t* sorted_indices_ptr = reinterpret_cast<int64_t*>(indices_ptr + indices_len);
-    int* order_ptr = reinterpret_cast<int*>(sorted_indices_ptr + indices_len);
-    int* is_insert = reinterpret_cast<int*>(order_ptr + indices_len);
-    int* origin_idx = reinterpret_cast<int*>(is_insert + outshape[axis]);
+    index_t* order_ptr = reinterpret_cast<index_t*>(sorted_indices_ptr + indices_len);
+    index_t* is_insert = reinterpret_cast<index_t*>(order_ptr + indices_len);
+    index_t* origin_idx = reinterpret_cast<index_t*>(is_insert + outshape[axis]);

Review comment:
       I see, we are using different sections of that temporary mem




----------------------------------------------------------------
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 commented on a change in pull request #19340: [FEATURE] Enable large tensor support for insert

Posted by GitBox <gi...@apache.org>.
sandeep-krishnamurthy commented on a change in pull request #19340:
URL: https://github.com/apache/incubator-mxnet/pull/19340#discussion_r518442488



##########
File path: tests/nightly/test_np_large_array.py
##########
@@ -2035,6 +2035,7 @@ def test_vstack():
 
 
 @use_np
+<<<<<<< HEAD

Review comment:
       merge conflicts.




----------------------------------------------------------------
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 #19340: [FEATURE] Enable large tensor support for insert

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


   


----------------------------------------------------------------
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 #19340: [FEATURE] Enable large tensor support for insert

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


   @access2rohit are you going to include `insert_tensor` and `delete` in this pr too?


----------------------------------------------------------------
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