mirror of
https://github.com/saymrwulf/onnxruntime.git
synced 2026-06-30 03:37:44 +00:00
Replace fabs with std::fabs (#1035)
fabs only accept double, there it needs float. Similar thing for log.
This commit is contained in:
parent
9029c496b0
commit
46bf6fd1ef
2 changed files with 4 additions and 4 deletions
|
|
@ -25,6 +25,7 @@
|
|||
#pragma warning(disable : 4996)
|
||||
#endif
|
||||
#include <algorithm>
|
||||
#include <cmath>
|
||||
#ifdef _MSC_VER
|
||||
#pragma warning(pop)
|
||||
#endif
|
||||
|
|
@ -79,7 +80,7 @@ common::Status SoftmaxCPU(const int64_t N,
|
|||
}
|
||||
} else {
|
||||
for (int i = 0; i < N; ++i) {
|
||||
auto log_fmaxf_scale_i = log(fmaxf(scale[i], 1e-20f));
|
||||
auto log_fmaxf_scale_i = std::log(fmaxf(scale[i], 1e-20f));
|
||||
for (int j = 0; j < D; ++j) {
|
||||
Ydata[i * D + j] = Xdata[i * D + j] - rowmax[i] - log_fmaxf_scale_i;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -39,9 +39,8 @@ template <typename T>
|
|||
inline T Sigmoid(T x, T alpha RNN_UNUSED_PARAMETER, T beta RNN_UNUSED_PARAMETER) {
|
||||
if (x >= 0) {
|
||||
return 1 / (1 + exp(-x));
|
||||
} else {
|
||||
return exp(x) / (1 + exp(x));
|
||||
}
|
||||
return exp(x) / (1 + exp(x));
|
||||
}
|
||||
|
||||
template <typename T>
|
||||
|
|
@ -69,7 +68,7 @@ inline T Softsign(T x, T alpha, T beta);
|
|||
|
||||
template <>
|
||||
inline float Softsign<float>(float x, float alpha ORT_ATTRIBUTE_UNUSED, float beta ORT_ATTRIBUTE_UNUSED) {
|
||||
return x / (1 + fabs(x));
|
||||
return x / (1 + std::fabs(x));
|
||||
}
|
||||
|
||||
template <>
|
||||
|
|
|
|||
Loading…
Reference in a new issue