Skip to content

Commit

Permalink
Fix tanh for large inputs
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 671189741
  • Loading branch information
impjdi authored and tensorflower-gardener committed Sep 5, 2024
1 parent 5b1c4dd commit ff48a2f
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions tensorflow/lite/delegates/gpu/common/tasks/elementwise.cc
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,8 @@ std::string GetOneInputCode(const GpuInfo& gpu_info,
"FLT4 exp_val = convert_half4(native_exp(2.0f * "
"convert_float4($1)));\n";
result +=
"$0 = ((exp_val - INIT_FLT4(1.0f)) / (exp_val + "
"INIT_FLT4(1.0f)));";
"$0 = isinf(exp_val) ? sign($1) : ((exp_val - INIT_FLT4(1.0f)) / "
"(exp_val + INIT_FLT4(1.0f)));\n";
} else {
result = "$0 = tanh($1);";
}
Expand Down

0 comments on commit ff48a2f

Please sign in to comment.