-
Notifications
You must be signed in to change notification settings - Fork 62
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Ensure MathsProvider template arguments are forwarded through ModelT:…
…:parseJson (#150) * Ensure MathsProvider template arguments are forwarded through ModelT::parseJson * Apply clang-format --------- Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
- Loading branch information
1 parent
32b8664
commit 46b1562
Showing
10 changed files
with
147 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
#pragma once | ||
|
||
#include <RTNeural/RTNeural.h> | ||
|
||
#if RTNEURAL_USE_XSIMD | ||
struct TestMathsProvider | ||
{ | ||
template <typename T> | ||
static T tanh(T x) { using std::tanh; using xsimd::tanh; return tanh(x); } | ||
template <typename T> | ||
static T sigmoid(T x) { using std::exp; using xsimd::exp; return (T)1 / ((T)1 + exp(-x)); } | ||
template <typename T> | ||
static T exp(T x) { using std::exp; using xsimd::exp; return exp(x); } | ||
}; | ||
#elif RTNEURAL_USE_EIGEN | ||
struct TestMathsProvider | ||
{ | ||
template <typename Matrix> | ||
static auto tanh(const Matrix& x) { return x.array().tanh(); } | ||
template <typename Matrix> | ||
static auto sigmoid(const Matrix& x) { using T = typename Matrix::Scalar; return (T)1 / (((T)-1 * x.array()).array().exp() + (T)1); } | ||
template <typename Matrix> | ||
static auto exp(const Matrix& x) { return x.array().exp(); } | ||
}; | ||
#else | ||
struct TestMathsProvider | ||
{ | ||
template <typename T> | ||
static T tanh(T x) { return std::tanh(x); } | ||
template <typename T> | ||
static T sigmoid(T x) { return (T)1 / ((T)1 + std::exp(-x)); } | ||
template <typename T> | ||
static T exp(T x) { return std::exp(x); } | ||
}; | ||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters