haojin2 commented on a change in pull request #11024: [MXNET-394] concat of CSR 
NDArrays on first dimension
URL: https://github.com/apache/incubator-mxnet/pull/11024#discussion_r192552621
 
 

 ##########
 File path: src/operator/nn/concat-inl.h
 ##########
 @@ -154,6 +154,82 @@ void ConcatGradCompute(const nnvm::NodeAttrs& attrs, 
const OpContext& ctx,
   });
 }
 
+
+struct concat_csr_first_dim {
+  // i is the i-th row of the output ndarray
+  template<typename DType, typename RType, typename IType>
+  MSHADOW_XINLINE static void Map(int i, const OpReqType req,
+                                  DType* out_data, const DType* in_data,
+                                  RType* out_indptr, const RType* in_indptr,
+                                  IType* out_idx, const IType* in_idx,
+                                  const nnvm::dim_t indptr_offset,
+                                  const nnvm::dim_t idx_offset) {
+    if (i == 0) out_indptr[0] = 0;
+    out_indptr[i+1+indptr_offset] = in_indptr[i+1] + idx_offset;
+    for (nnvm::dim_t j = in_indptr[i]; j < in_indptr[i+1]; ++j) {
+      KERNEL_ASSIGN(out_idx[j+idx_offset], req, in_idx[j]);
+      KERNEL_ASSIGN(out_data[j+idx_offset], req, in_data[j]);
+    }
+  }
+};
+
+
+
+template<typename xpu>
+void ConcatRspImpl(const nnvm::NodeAttrs& attrs,
+                   const OpContext& ctx,
+                   const std::vector<NDArray>& inputs,
+                   const std::vector<OpReqType>& req,
+                   const std::vector<NDArray>& outputs) {
+  if (req[0] == kNullOp) return;
 
 Review comment:
   Better do this after all the checks below?

----------------------------------------------------------------
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:
[email protected]


With regards,
Apache Git Services

Reply via email to