haojin2 commented on a change in pull request #11356: [MXNET-560][WIP] Add 
temperature parameter in Softmax and SoftmaxOutput operator
URL: https://github.com/apache/incubator-mxnet/pull/11356#discussion_r197924316
 
 

 ##########
 File path: src/operator/nn/softmax-inl.h
 ##########
 @@ -127,7 +137,7 @@ inline void SoftmaxGrad(Stream<cpu> *s, DType *out, DType 
*ograd,
 #ifdef __CUDACC__
 template<int x_bits, typename OP, typename DType, int ndim>
 __global__ void softmax_compute_kernel(DType *in, DType *out, index_t M, int 
axis,
-                                       Shape<ndim> sshape, Shape<ndim> stride) 
{
+                                       Shape<ndim> sshape, Shape<ndim> stride, 
float temperature) {
 
 Review comment:
   adding `const` qualifier could be a safe net by explicitly telling the 
compiler about your assumption that you're not changing the input value at all 
in the function.
   Say if you have a function like this:
   ```c++
   void foo(int a) {
     return a;
   }
   ```
   Here your assumption that the original input should be returned without any 
changes, and that is essential for correct behavior of this function.
   Now if someone happens to change the function to:
   ```c++
   void foo(int a) {
     a++;      // <- new code that happens to change the value of a, and will 
affect correctness
     return a;
   }
   ```
   compiler will not complain about it as you do not have a `const` qualifier 
here, so an extra `const` qualifier is not necessary, but it could be helpful.

----------------------------------------------------------------
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