From dev-return-3900-archive-asf-public=cust-asf.ponee.io@singa.apache.org Thu Nov 14 14:04:34 2019 Return-Path: X-Original-To: archive-asf-public@cust-asf.ponee.io Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [207.244.88.153]) by mx-eu-01.ponee.io (Postfix) with SMTP id 6DB81180607 for ; Thu, 14 Nov 2019 15:04:34 +0100 (CET) Received: (qmail 23376 invoked by uid 500); 14 Nov 2019 14:04:33 -0000 Mailing-List: contact dev-help@singa.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@singa.apache.org Delivered-To: mailing list dev@singa.apache.org Received: (qmail 23366 invoked by uid 99); 14 Nov 2019 14:04:33 -0000 Received: from ec2-52-202-80-70.compute-1.amazonaws.com (HELO gitbox.apache.org) (52.202.80.70) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 14 Nov 2019 14:04:33 +0000 From: GitBox To: dev@singa.apache.org Subject: [GitHub] [singa] chrishkchris edited a comment on issue #552: SINGA-496 Implement softplus and softsign functions for tensor math Message-ID: <157374027369.6782.16321843307706325918.gitbox@gitbox.apache.org> Date: Thu, 14 Nov 2019 14:04:33 -0000 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit chrishkchris edited a comment 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::fabsf(in[i]) + 1); } } void softsign(const size_t n, const float *in, float *out, cudaStream_t s) { KernelSoftsign <<>> (n, in, out); } More accurately, you may try this fabsf in the cuda math api https://docs.nvidia.com/cuda/cuda-math-api/group__CUDA__MATH__SINGLE.html#group__CUDA__MATH__SINGLE_1gb00f8593e1bfb1985526020fbec4e0fc ---------------------------------------------------------------- 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: users@infra.apache.org With regards, Apache Git Services