reminisce commented on a change in pull request #9481: add where op with sparse 
condition
URL: https://github.com/apache/incubator-mxnet/pull/9481#discussion_r162494943
 
 

 ##########
 File path: src/operator/tensor/control_flow_op.h
 ##########
 @@ -87,6 +117,37 @@ struct where_backward {
   }
 };
 
+/*!
+ * \brief Template for calculating grad[x] and grad[y].
+ * template argument req is OpReqType; negate indicates
+ * whether the output is grad_x (negate=true)
+ * or grad_y (negate=false).
+ * cond is a csr matrix, while others are dense ones.
+ */
+template<int req, bool negate>
+struct where_backward_csr {
+  // DType is the output data type
+  // CType is condition data type
+  // IType is condition aux data type
+  template<typename DType, typename CType, typename IType>
+  MSHADOW_XINLINE static void Map(int i, DType* grad_out,
+                                  const DType* grad_in,
+                                  const CType* cond_data,
+                                  const IType* cond_idx,
+                                  const IType* cond_indptr,
+                                  const nnvm::dim_t num_cols) {
+    const IType offset = i * num_cols;
+    const DType zero = static_cast<DType>(0);
+    for (IType j = cond_indptr[i]; j < cond_indptr[i + 1]; j++) {
+      IType col = cond_idx[j];
 
 Review comment:
   const IType

----------------------------------------------------------------
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:
us...@infra.apache.org


With regards,
Apache Git Services

Reply via email to