Upgraded eigen to the latest version
Change: 129887348
This commit is contained in:
parent
d027643a74
commit
3c5774d5d1
@ -386,61 +386,20 @@ struct logical_not : base<bool, Eigen::internal::scalar_boolean_not_op<bool> > {
|
|||||||
// NOTE: std::isinf, std::isnan, std::isfinite are plain function.
|
// NOTE: std::isinf, std::isnan, std::isfinite are plain function.
|
||||||
// Therefore we need to wrap them in functors to be used with Eigen's
|
// Therefore we need to wrap them in functors to be used with Eigen's
|
||||||
// type system.
|
// type system.
|
||||||
|
template <typename T>
|
||||||
|
struct isinf : base<T, Eigen::internal::scalar_isinf_op<T>, bool> {};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct isinf_func {
|
struct isnan : base<T, Eigen::internal::scalar_isnan_op<T>, bool> {};
|
||||||
typedef bool result_type;
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator()(T x) const {
|
|
||||||
return Eigen::numext::isinf(x);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct isinf : base<T, isinf_func<T>, bool> {};
|
struct isfinite : base<T, Eigen::internal::scalar_isfinite_op<T>, bool> {};
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct isnan_func {
|
struct floor : base<T, Eigen::internal::scalar_floor_op<T>> {};
|
||||||
typedef bool result_type;
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator()(T x) const {
|
|
||||||
return Eigen::numext::isnan(x);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
template <typename T>
|
||||||
struct isnan : base<T, isnan_func<T>, bool> {};
|
struct ceil : base<T, Eigen::internal::scalar_ceil_op<T>> {};
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct isfinite_func {
|
|
||||||
typedef bool result_type;
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool operator()(T x) const {
|
|
||||||
return Eigen::numext::isfinite(x);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct isfinite : base<T, isfinite_func<T>, bool> {};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct floor_func {
|
|
||||||
typedef T result_type;
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T operator()(T x) const {
|
|
||||||
return Eigen::numext::floor(x);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct floor : base<T, floor_func<T> > {};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct ceil_func {
|
|
||||||
typedef T result_type;
|
|
||||||
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T operator()(T x) const {
|
|
||||||
return Eigen::numext::ceil(x);
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
template <typename T>
|
|
||||||
struct ceil : base<T, ceil_func<T> > {};
|
|
||||||
|
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
// Binary functors
|
// Binary functors
|
||||||
|
@ -110,7 +110,7 @@ struct CopyThatWorksWithStringPointer<Eigen::half> {
|
|||||||
d(d_start[0] + i0, d_start[1] + i1, d_start[2] + i2,
|
d(d_start[0] + i0, d_start[1] + i1, d_start[2] + i2,
|
||||||
d_start[3] + i3, d_start[4] + i4, d_start[5] + i5,
|
d_start[3] + i3, d_start[4] + i4, d_start[5] + i5,
|
||||||
d_start[6] + i6, d_start[7] + i7) =
|
d_start[6] + i6, d_start[7] + i7) =
|
||||||
Eigen::internal::raw_uint16_to_half(
|
Eigen::half_impl::raw_uint16_to_half(
|
||||||
s(s_start[0] + i0, s_start[1] + i1, s_start[2] + i2,
|
s(s_start[0] + i0, s_start[1] + i1, s_start[2] + i2,
|
||||||
s_start[3] + i3, s_start[4] + i4, s_start[5] + i5,
|
s_start[3] + i3, s_start[4] + i4, s_start[5] + i5,
|
||||||
s_start[6] + i6, s_start[7] + i7));
|
s_start[6] + i6, s_start[7] + i7));
|
||||||
|
@ -55,13 +55,13 @@ def SortEigenDecomposition(e, v):
|
|||||||
|
|
||||||
def _GetSelfAdjointEigTest(dtype_, shape_):
|
def _GetSelfAdjointEigTest(dtype_, shape_):
|
||||||
|
|
||||||
def CompareEigenVectors(self, x, y, atol):
|
def CompareEigenVectors(self, x, y, tol):
|
||||||
# Eigenvectors are only unique up to sign so we normalize the signs first.
|
# Eigenvectors are only unique up to sign so we normalize the signs first.
|
||||||
signs = np.sign(np.sum(np.divide(x, y), -2, keepdims=True))
|
signs = np.sign(np.sum(np.divide(x, y), -2, keepdims=True))
|
||||||
x *= signs
|
x *= signs
|
||||||
self.assertAllClose(x, y, atol)
|
self.assertAllClose(x, y, atol=tol, rtol=tol)
|
||||||
|
|
||||||
def CompareEigenDecompositions(self, x_e, x_v, y_e, y_v, atol):
|
def CompareEigenDecompositions(self, x_e, x_v, y_e, y_v, tol):
|
||||||
num_batches = int(np.prod(x_e.shape[:-1]))
|
num_batches = int(np.prod(x_e.shape[:-1]))
|
||||||
n = x_e.shape[-1]
|
n = x_e.shape[-1]
|
||||||
x_e = np.reshape(x_e, [num_batches] + [n])
|
x_e = np.reshape(x_e, [num_batches] + [n])
|
||||||
@ -71,8 +71,8 @@ def _GetSelfAdjointEigTest(dtype_, shape_):
|
|||||||
for i in range(num_batches):
|
for i in range(num_batches):
|
||||||
x_ei, x_vi = SortEigenDecomposition(x_e[i, :], x_v[i, :, :])
|
x_ei, x_vi = SortEigenDecomposition(x_e[i, :], x_v[i, :, :])
|
||||||
y_ei, y_vi = SortEigenDecomposition(y_e[i, :], y_v[i, :, :])
|
y_ei, y_vi = SortEigenDecomposition(y_e[i, :], y_v[i, :, :])
|
||||||
self.assertAllClose(x_ei, y_ei, atol=atol)
|
self.assertAllClose(x_ei, y_ei, atol=tol, rtol=tol)
|
||||||
CompareEigenVectors(self, x_vi, y_vi, atol)
|
CompareEigenVectors(self, x_vi, y_vi, tol)
|
||||||
|
|
||||||
def Test(self):
|
def Test(self):
|
||||||
np.random.seed(1)
|
np.random.seed(1)
|
||||||
@ -85,7 +85,7 @@ def _GetSelfAdjointEigTest(dtype_, shape_):
|
|||||||
if dtype_ == np.float32:
|
if dtype_ == np.float32:
|
||||||
atol = 1e-4
|
atol = 1e-4
|
||||||
else:
|
else:
|
||||||
atol = 1e-14
|
atol = 1e-12
|
||||||
for compute_v in False, True:
|
for compute_v in False, True:
|
||||||
np_e, np_v = np.linalg.eig(a)
|
np_e, np_v = np.linalg.eig(a)
|
||||||
with self.test_session():
|
with self.test_session():
|
||||||
|
@ -7,8 +7,8 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
|
|||||||
|
|
||||||
# These lines need to be changed when updating Eigen. They are parsed from
|
# These lines need to be changed when updating Eigen. They are parsed from
|
||||||
# this file by the cmake and make builds to determine the eigen version and hash.
|
# this file by the cmake and make builds to determine the eigen version and hash.
|
||||||
eigen_version = "b4fa9622b809"
|
eigen_version = "6f952374ef2b"
|
||||||
eigen_sha256 = "2862840c2de9c0473a4ef20f8678949ae89ab25965352ee53329e63ba46cec62"
|
eigen_sha256 = "56d658324b09de3f418ae42ca0646dd1e6e0b897dd58b164ec0d21315764afd9"
|
||||||
|
|
||||||
native.new_http_archive(
|
native.new_http_archive(
|
||||||
name = "eigen_archive",
|
name = "eigen_archive",
|
||||||
|
Loading…
Reference in New Issue
Block a user