apeforest commented on a change in pull request #15169: Softmax with length
URL: https://github.com/apache/incubator-mxnet/pull/15169#discussion_r303652418
 
 

 ##########
 File path: src/operator/nn/softmax-inl.h
 ##########
 @@ -177,6 +231,51 @@ inline void SoftmaxGrad(Stream<cpu> *s, OType *out, OType 
*ograd,
   }
 }
 
+template<typename OP1, typename OP2, int Req, bool negate,
+  typename AType, typename DType, typename OType, typename IType, int ndim>
+inline void SoftmaxWithLengthGrad(Stream<cpu> *s, OType *out, OType *ograd,
+                                  DType *igrad, IType *length, Shape<ndim> 
shape,
+                                  int axis, const DType temperature) {
+  index_t M = shape[axis];
+  index_t N = shape.Size()/M;
+  Shape<ndim> stride = calc_stride(shape);
+  Shape<ndim> sshape = shape;
+  sshape[axis] = 1;
+  index_t sa = stride[axis];
+
+  #pragma omp parallel for
+  for (int i = 0; i < static_cast<int>(N); ++i) {
 
 Review comment:
   Please use `index_t` instead of `int`

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


With regards,
Apache Git Services

Reply via email to