chrishkchris commented on issue #552: SINGA-496 Implement softplus and softsign 
functions for tensor math
URL: https://github.com/apache/singa/pull/552#issuecomment-553900186
 
 
   For example, it is something like this (the following is for reference which 
is not tested):
   
   1. In math_kernal.h, it may be like this:
   
   void softsign(const size_t n, const float *in, float *out, cudaStream_t s);
   
   2. In math_kernal.cu, it may be like this:
   
   __global__ void KernelSoftsign(const size_t n, const float *in, float *out) {
     for (int i = blockIdx.x * blockDim.x + threadIdx.x; i < n;
          i += blockDim.x * gridDim.x) {
       out[i] = in[i] / (std::abs(in[i]) + 1);
     }
   }
   
   void softsign(const size_t n, const float *in, float *out, cudaStream_t s) {
     KernelSoftsign <<<ceil(n / CU1DBLOCKF), CU1DBLOCKF, 0, s>>> (n, in, out);
   }
   

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


With regards,
Apache Git Services

Reply via email to