upgrade eigen to 3.4.0

This commit is contained in:
zhujingxuan 2022-07-13 15:52:42 +08:00
parent 221c009c44
commit 07b5268fc7
3 changed files with 12 additions and 10 deletions

View File

@ -2,16 +2,16 @@ set(Eigen3_CXXFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(Eigen3_CFLAGS "-D_FORTIFY_SOURCE=2 -O2")
set(REQ_URL "https://gitlab.com/libeigen/eigen/-/archive/3.3.9/eigen-3.3.9.tar.gz")
set(MD5 "609286804b0f79be622ccf7f9ff2b660")
set(REQ_URL "https://gitlab.com/libeigen/eigen/-/archive/3.4.0/eigen-3.4.0.tar.gz")
set(MD5 "4c527a9171d71a72a9d4186e65bea559")
mindspore_add_pkg(Eigen3
VER 3.3.9
VER 3.4.0
URL ${REQ_URL}
MD5 ${MD5}
CMAKE_OPTION -DBUILD_TESTING=OFF)
find_package(Eigen3 3.3.9 REQUIRED ${MS_FIND_NO_DEFAULT_PATH})
find_package(Eigen3 3.4.0 REQUIRED ${MS_FIND_NO_DEFAULT_PATH})
include_directories(${Eigen3_INC})
include_directories(${EIGEN3_INCLUDE_DIR})
set_property(TARGET Eigen3::Eigen PROPERTY IMPORTED_GLOBAL TRUE)

View File

@ -48,7 +48,7 @@ static EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE uint64_t PCG_XSH_RS_state(uint64_t
} // namespace
template <typename T>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T RandomToTypePoisson(uint64_t *state, double rate) {
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T RandomToTypePoisson(uint64_t *state, uint64_t m_stream, double rate) {
using Eigen::numext::exp;
using Eigen::numext::log;
using Eigen::numext::pow;
@ -63,7 +63,7 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T RandomToTypePoisson(uint64_t *state, dou
// Keep trying until we surpass e^(-rate). This will take
// expected time proportional to rate.
while (true) {
double u = Eigen::internal::RandomToTypeUniform<double>(state);
double u = Eigen::internal::RandomToTypeUniform<double>(state, m_stream);
prod = prod * u;
if (prod <= exp_neg_rate && x <= static_cast<double>(Eigen::NumTraits<T>::highest())) {
result = static_cast<T>(x);
@ -83,9 +83,9 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T RandomToTypePoisson(uint64_t *state, dou
const double inv_alpha = static_cast<double>(1.1239) + static_cast<double>(1.1328) / (b - static_cast<double>(3.4));
while (true) {
double u = Eigen::internal::RandomToTypeUniform<double>(state);
double u = Eigen::internal::RandomToTypeUniform<double>(state, m_stream);
u -= static_cast<double>(0.5);
double v = Eigen::internal::RandomToTypeUniform<double>(state);
double v = Eigen::internal::RandomToTypeUniform<double>(state, m_stream);
double u_shifted = static_cast<double>(0.5) - Eigen::numext::abs(u);
double k =
Eigen::numext::floor((static_cast<double>(2) * a / u_shifted + b) * u + rate + static_cast<double>(0.43));
@ -130,13 +130,16 @@ class PoissonRandomGenerator {
}
void setRate(double rate) { m_rate = rate; }
T gen() const {
T result = RandomToTypePoisson<T>(&m_state, m_rate);
T result = RandomToTypePoisson<T>(&m_state, m_stream, m_rate);
return result;
}
private:
double m_rate;
mutable uint64_t m_state;
// Adapt Eigen 3.4.0 new api for stream random number generator.
// Here's no parallel computing, so we set stream to any fixed value.
static constexpr uint64_t m_stream = 0;
};
bool AddrAlignedCheck(const void *addr, uint64_t alignment = 16) {

View File

@ -19,7 +19,6 @@
#include <memory>
#include <vector>
#include "Eigen/Core"
#include "Eigen/src/Core/arch/CUDA/Half.h"
#include "abstract/utils.h"
#include "plugin/device/cpu/hal/device/cpu_common.h"
#include "include/common/utils/python_adapter.h"