Skip to content

Commit

Permalink
Revert "Always use Stan's eigen fix #4288"
Browse files Browse the repository at this point in the history
This reverts commit eca71c6.
  • Loading branch information
vigsterkr committed Feb 27, 2020
1 parent 53b8fb3 commit 2565343
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 119 deletions.
1 change: 1 addition & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ IF(NOT HAVE_STD_STRING_VIEW)
ENDIF()

############# minimum library versions ###################
SET(EIGEN_VERSION_MINIMUM 3.1.2)
SET(VIENNACL_VERSION_MINIMUM 1.5.0)

# Store system's or distribution's C[XX]FLAGS.
Expand Down
2 changes: 0 additions & 2 deletions NEWS
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
framework [Heiko Strathmann, Sergey Lisitsyn]
- Removal of computation engine framework and parallelisation of
log-determinant estimators [Shubham Shukla]
- Add StanMath as a bundled third-party library and use Eigen
shipped with StanMath [Elfarouk Yasser, Viktor Gal]
- Efficiency improvements for MahalanobisDistance, LMNN, ridge
regression, GMM, and the linalg framework [Wuwei Lin]
- Add LDLT decomposition to linalg [Wuwei Lin]
Expand Down
47 changes: 47 additions & 0 deletions cmake/FindEigen3.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# - Try to find Eigen3 lib
#
# This module supports requiring a minimum version, e.g. you can do
# find_package(Eigen3 3.1.2)
# to require version 3.1.2 or newer of Eigen3.
#
# Once done this will define
#
# EIGEN_FOUND - system has eigen lib with correct version
# EIGEN_INCLUDE_DIR - the eigen include directory
# EIGEN_VERSION - eigen version

# Copyright (c) 2006, 2007 Montel Laurent, <montel@kde.org>
# Copyright (c) 2008, 2009 Gael Guennebaud, <g.gael@free.fr>
# Copyright (c) 2009 Benoit Jacob <jacob.benoit.1@gmail.com>
# Redistribution and use is allowed according to the terms of the 2-clause BSD license.

macro(_eigen3_get_version)
file(READ "${EIGEN_INCLUDE_DIR}/Eigen/src/Core/util/Macros.h" _eigen3_version_header)

string(REGEX MATCH "define[ \t]+EIGEN_WORLD_VERSION[ \t]+([0-9]+)" _eigen3_world_version_match "${_eigen3_version_header}")
set(EIGEN_WORLD_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MAJOR_VERSION[ \t]+([0-9]+)" _eigen3_major_version_match "${_eigen3_version_header}")
set(EIGEN_MAJOR_VERSION "${CMAKE_MATCH_1}")
string(REGEX MATCH "define[ \t]+EIGEN_MINOR_VERSION[ \t]+([0-9]+)" _eigen3_minor_version_match "${_eigen3_version_header}")
set(EIGEN_MINOR_VERSION "${CMAKE_MATCH_1}")

set(EIGEN_VERSION ${EIGEN_WORLD_VERSION}.${EIGEN_MAJOR_VERSION}.${EIGEN_MINOR_VERSION})

endmacro(_eigen3_get_version)

find_path(EIGEN_INCLUDE_DIR NAMES signature_of_eigen3_matrix_library
PATHS
${CMAKE_INSTALL_PREFIX}/include
PATH_SUFFIXES eigen3 eigen
)

if(EIGEN_INCLUDE_DIR)
_eigen3_get_version()
endif(EIGEN_INCLUDE_DIR)

include(FindPackageHandleStandardArgs)
find_package_handle_standard_args (Eigen3 REQUIRED_VARS EIGEN_INCLUDE_DIR VERSION_VAR EIGEN_VERSION)

mark_as_advanced(EIGEN_INCLUDE_DIR)
SET(EIGEN_INCLUDE_DIRS ${EIGEN_INCLUDE_DIR} CACHE PATH "The Eigen include path.")

5 changes: 3 additions & 2 deletions cmake/ShogunFindLAPACK.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -122,8 +122,9 @@ IF (LAPACK_FOUND)
ENDIF()
ENDIF()
ENDIF()
# if LaPack is detected use the lapack/blas backend in Eigen
IF(ENABLE_EIGEN_LAPACK AND HAVE_LAPACK)
# if LaPack is detected and Eigen is 3.3 or later
# use the lapack/blas backend in Eigen
IF(${EIGEN_VERSION} VERSION_GREATER 3.3.0 AND ENABLE_EIGEN_LAPACK AND HAVE_LAPACK)
SET(EIGEN_USE_BLAS 1)
MESSAGE(STATUS "Enabling detected BLAS library as backend for Eigen")

Expand Down
22 changes: 22 additions & 0 deletions cmake/external/Eigen3.cmake
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
set(EIGEN_INCLUDE_DIR ${THIRD_PARTY_INCLUDE_DIR}/eigen)
set(EIGEN_VERSION 3.3.4)
include(ExternalProject)
ExternalProject_Add(
Eigen3
PREFIX ${CMAKE_BINARY_DIR}/Eigen3
DOWNLOAD_DIR ${THIRD_PARTY_DIR}/Eigen3
URL https://bitbucket.org/eigen/eigen/get/${EIGEN_VERSION}.tar.bz2
URL_MD5 a7aab9f758249b86c93221ad417fbe18
CMAKE_ARGS -DINCLUDE_INSTALL_DIR:STRING=${EIGEN_INCLUDE_DIR}
-DCMAKE_C_FLAGS:STRING=${CMAKE_C_FLAGS}${CMAKE_DEFINITIONS}
-DCMAKE_CXX_FLAGS:STRING=${CMAKE_CXX_FLAGS}${CMAKE_DEFINITIONS}
-DCMAKE_C_COMPILER:STRING=${CMAKE_C_COMPILER}
-DCMAKE_CXX_COMPILER:STRING=${CMAKE_CXX_COMPILER}
-DCMAKE_BUILD_TYPE:STRING=Release
-DEIGEN_BUILD_PKGCONFIG=0
)

add_dependencies(libshogun Eigen3)

UNSET(C_COMPILER)
UNSET(CXX_COMPILER)
21 changes: 0 additions & 21 deletions cmake/external/StanMath.cmake

This file was deleted.

1 change: 0 additions & 1 deletion examples/meta/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@ ADD_CUSTOM_COMMAND(OUTPUT ${CTAGS_FILE}
--exclude=third_party
--exclude=GoogleMock
--exclude=rxcpp
--exclude=StanMath
--exclude=interfaces
--exclude=Eigen3
--exclude=external
Expand Down
35 changes: 15 additions & 20 deletions src/shogun/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -297,27 +297,22 @@ endif()

############################ external dependencies

#Stan math
include(external/StanMath)

SHOGUN_INCLUDE_DIRS(SCOPE PUBLIC SYSTEM
$<BUILD_INTERFACE:${STAN_INCLUDE_DIR_STAN_MATH}>
$<INSTALL_INTERFACE:include/shogun/third_party/stan>
)
SHOGUN_INCLUDE_DIRS(SCOPE PUBLIC SYSTEM
$<BUILD_INTERFACE:${STAN_INCLUDE_DIR_BOOST}>
$<INSTALL_INTERFACE:include/shogun/third_party/stan_boost>
)
SHOGUN_INCLUDE_DIRS(SCOPE PUBLIC SYSTEM
$<BUILD_INTERFACE:${STAN_INCLUDE_DIR_SUNDIALS}>
$<INSTALL_INTERFACE:include/shogun/third_party/stan_sundials>
)
SHOGUN_INCLUDE_DIRS(SCOPE PUBLIC SYSTEM
$<BUILD_INTERFACE:${STAN_INCLUDE_DIR_EIGEN}>
$<INSTALL_INTERFACE:include/shogun/third_party/eigen>
)

####### LINALG
FIND_PACKAGE(Eigen3 ${EIGEN_VERSION_MINIMUM})
IF(NOT EIGEN3_FOUND)
include(external/Eigen3)
SHOGUN_INCLUDE_DIRS(SCOPE PUBLIC SYSTEM
$<BUILD_INTERFACE:${EIGEN_INCLUDE_DIR}>
$<INSTALL_INTERFACE:include/shogun/third_party/eigen>
)
ELSE()
# eigen3 bug related to aliasing operators and self-storing.
IF(${EIGEN_VERSION} VERSION_GREATER 3.2.90 AND ${EIGEN_VERSION} VERSION_LESS 3.3.0)
MESSAGE(WARNING "The system Eigen3 version ${EIGEN_VERSION} contains a lot of bugs, which could cause some models failing!")
ENDIF()
SHOGUN_INCLUDE_DIRS(SCOPE PUBLIC SYSTEM ${EIGEN_INCLUDE_DIR})
ENDIF()

# ViennaCL detection
SHOGUN_DEPENDENCIES(
LIBRARY ViennaCL
Expand Down
73 changes: 0 additions & 73 deletions tests/unit/StanMath/StanPerceptronTest_unittest.cc

This file was deleted.

0 comments on commit 2565343

Please sign in to comment.