Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,12 @@ package io.kinference.core.operators.math

import kotlin.math.exp

inline fun tanh(value: Float): Float {
fun tanh(value: Float): Float {
var temp = exp(2.0f * value)
if (temp.isInfinite()) temp = Float.MAX_VALUE
return ((temp - 1.0f) / (temp + 1.0f))
}

inline fun tanh(value: Double): Double {
fun tanh(value: Double): Double {
return ((exp(2.0 * value) - 1.0) / (exp(2.0 * value) + 1.0))
}