提交 83b9d1c5 编写于 作者: M mindspore-ci-bot 提交者: Gitee

!5319 [MS][LITE][Develop]optimize tanh

Merge pull request !5319 from chenjianping/lite_dev2
......@@ -62,7 +62,14 @@ int Sigmoid(const float *src, int length, float *dst) {
int Tanh(const float *src, int length, float *dst) {
for (int i = 0; i < length; ++i) {
dst[i] = 1.0f - 2.0f / (exp(2 * src[i]) + 1);
float tmp_in = src[i];
if (tmp_in > 5.0) {
dst[i] = 1.0f;
} else if (tmp_in < -5.0) {
dst[i] = -1.0f;
} else {
dst[i] = 1.0f - 2.0f / (exp(2 * tmp_in) + 1);
}
}
return NNACL_OK;
}
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册