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/01/30 23:45:55 UTC
[GitHub] eric-haibin-lin commented on a change in pull request #9625: sparse regression operators
eric-haibin-lin commented on a change in pull request #9625: sparse regression operators
URL: https://github.com/apache/incubator-mxnet/pull/9625#discussion_r164914751
##########
File path: src/operator/regression_output-inl.h
##########
@@ -121,6 +174,80 @@ void RegressionBackward(const nnvm::NodeAttrs& attrs,
});
}
+/*!
+ * \brief Regression backward kernel for the case that
+ * label is of csr storage type.
+ * Parallelize by each row.
+ */
+template<typename OP, int req>
+struct SparseRegressionBWDKernel {
+ template<typename DType, typename IType, typename RType>
+ MSHADOW_XINLINE static void Map(int i, DType* out_data,
+ const DType* in_data,
+ const DType* label_data,
+ const IType* label_idx,
+ const RType* label_indptr,
+ const nnvm::dim_t row_length) {
+ nnvm::dim_t row_i = i * row_length;
+ RType k = label_indptr[i];
+ for (nnvm::dim_t j=0; j < row_length; j++) {
+ if (label_idx[k] == j) {
Review comment:
This creates many branches and hurts performance. What about do it in 2 passes? First copy in_data, then apply minus/minus_sign only for non-zero entries?
----------------------------------------------------------------
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