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 2018/10/29 03:02:28 UTC

[GitHub] rongzha1 commented on a change in pull request #12997: A better take forward kernel for CPU

rongzha1 commented on a change in pull request #12997: A better take forward kernel for CPU
URL: https://github.com/apache/incubator-mxnet/pull/12997#discussion_r228786026
 
 

 ##########
 File path: src/operator/tensor/indexing_op.cc
 ##########
 @@ -28,6 +28,28 @@
 namespace mxnet {
 namespace op {
 
+template<bool clip = true>
+struct TakeCPU {
+  // assume that idx have been flattened to a 1-D tensor (N,)
+  // assume that out_data and in_data have been flattened to 2-D tensors, (N, M) and (K, M)
+  // M is the number of columns of in_data and out_data
+  // K is the number of rows of in_data
+  // i is the index of out_data
+  template<typename DType, typename IType>
+  MSHADOW_XINLINE static void Map(int i, DType* out_data, const DType* in_data,
+                                  const IType* idx, const size_t M, const int64_t K) {
+    int64_t j = static_cast<int64_t>(idx[i]);
 
 Review comment:
   Can you tell why  use idx[i]?  Origin is idx[i/M] 
   Thanks

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on 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


With regards,
Apache Git Services