Tensara Logo

tensara

Hard Sigmoid

EASY

Perform the Hard Sigmoid activation function on an input matrix:

C[i][j]=hard_sigmoid(A[i][j])C[i][j] = \text{hard\_sigmoid}(A[i][j])

The Hard Sigmoid function is defined as:

hard_sigmoid(x)={0if x31if x3x+36otherwise\text{hard\_sigmoid}(x) = \begin{cases} 0 & \text{if } x \leq -3 \\ 1 & \text{if } x \geq 3 \\ \frac{x + 3}{6} & \text{otherwise} \end{cases}

Input:

  • Matrix AA of size M×NM \times N containing floating-point values

Output:

  • Matrix CC of size M×NM \times N containing the Hard Sigmoid activation values

Notes:

  • Both matrices A\text{A} and C\text{C} are stored in row-major order
  • The Hard Sigmoid function is a piecewise linear approximation of the standard Sigmoid function

GPU Type

Language

Data Type

Loading...

Loading editor...

CUDA C++ environment

Sample Run Results

Hit "Run" to test your code with sample inputs

Desktop Required for Code Submission

For the best coding experience, please switch to a desktop device to write and submit your solution.