Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New fastad integration nuts #46

Merged
merged 32 commits into from Aug 25, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
6e023e3
Restructure all classes to reuse a lot of tools from fastad
JamesYang007 Aug 2, 2020
950474f
Support MH fully
JamesYang007 Aug 2, 2020
097478a
Support NUTS fully
JamesYang007 Aug 2, 2020
faf9905
Refactored everything except mcmc
JamesYang007 Aug 3, 2020
5568054
First attempt at removing armadillo
JamesYang007 Aug 3, 2020
85f4eda
Add more data locality
JamesYang007 Aug 3, 2020
e486164
Change build tree to use only 1 cache line
JamesYang007 Aug 4, 2020
ab79d71
Increase threshold for nuts unittest
JamesYang007 Aug 4, 2020
712c648
Fix dumb compiler issues for gcc
JamesYang007 Aug 4, 2020
4eb5653
Change second regression benchmark example
JamesYang007 Aug 4, 2020
c51ccdf
Remove armadillo from library
JamesYang007 Aug 4, 2020
b18bc85
remove armadillo from benchmark
JamesYang007 Aug 4, 2020
4f84619
Update readme removing armadillo and adding eigen, setup and cmake
JamesYang007 Aug 4, 2020
2ba96f0
Remove functional and unnecessary math utils
JamesYang007 Aug 4, 2020
6345f3d
Add example of ESS where if-else branching occurs
JamesYang007 Aug 4, 2020
2d9da28
Add discrete example to MH
JamesYang007 Aug 4, 2020
5e59e69
Fix bug in logging
JamesYang007 Aug 4, 2020
c96953f
Add config for mh, unify mcmc result, add bayes net example with mh
JamesYang007 Aug 4, 2020
b7af5e1
Add support for covariance matrix
JamesYang007 Aug 5, 2020
5c14a27
Delete accidentally tracked metafiles
JamesYang007 Aug 5, 2020
a653c8d
Ignore all stan produced files
JamesYang007 Aug 5, 2020
7ff8b4c
Fully support constraints mechanism
JamesYang007 Aug 13, 2020
c02cb3a
Update README and example code
JamesYang007 Aug 13, 2020
da63af0
Fix uniform unused get lambda
JamesYang007 Aug 13, 2020
acb5723
Make travis run the two tests that are failing
JamesYang007 Aug 13, 2020
400438c
Undo running the two tests
JamesYang007 Aug 13, 2020
6a9b558
Add more unittests
JamesYang007 Aug 13, 2020
4bf57b6
Fully tested tp expressions with stochastic volatility
JamesYang007 Aug 20, 2020
8124a6c
Add stochastic volatility benchmark code
JamesYang007 Aug 20, 2020
f7f965c
Change stochastic volatility data with random seed
JamesYang007 Aug 20, 2020
28b19c6
Generalize constraint with any variable expression
JamesYang007 Aug 24, 2020
9748909
Add install to cmake and update readme
JamesYang007 Aug 25, 2020
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Expand Up @@ -5,3 +5,6 @@ build
lib/*
!lib/CMakeLists.txt
CMakeSettings.json
test/mcmc/hmc/nuts/ref/*_stan*
!test/mcmc/hmc/nuts/ref/*_stan.py
!test/mcmc/hmc/nuts/ref/*_stan.stan
91 changes: 61 additions & 30 deletions CMakeLists.txt
@@ -1,6 +1,6 @@
cmake_minimum_required(VERSION 3.7)
project("autoppl"
VERSION 0.8
project("AutoPPL"
VERSION 1.1
DESCRIPTION "C++ template library for probabilistic programming."
LANGUAGES C CXX)

Expand All @@ -9,38 +9,18 @@ option(AUTOPPL_ENABLE_BENCHMARK "Enable benchmarks to be built." OFF)
option(AUTOPPL_ENABLE_TEST_COVERAGE "Build with test coverage (AUTOPPL_ENABLE_TEST must be ON)" OFF)
option(AUTOPPL_ENABLE_EXAMPLE "Enable compilation of examples." OFF)

# Automate the choosing of config
if (NOT CMAKE_BUILD_TYPE)
# if binary directory ends with "release", use release mode
if (${PROJECT_BINARY_DIR} MATCHES "release$")
set(CMAKE_BUILD_TYPE RELEASE)
add_compile_options(-O3)
# otherwise, use debug mode
else()
set(CMAKE_BUILD_TYPE DEBUG)
endif()
endif()
message(STATUS "Compiling in ${CMAKE_BUILD_TYPE} mode")

# Add this library as interface (header-only)
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME}
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)
# This is to make this library portable to other machines.
# This will be used for install.
include(GNUInstallDirs)

# Add AutoPPL header-only library to variable
set(AUTOPPL_LIBS ${PROJECT_NAME})

# Find Armadillo C++
find_package(Armadillo CONFIG REQUIRED
HINTS ${CMAKE_CURRENT_SOURCE_DIR}/lib/armadillo)
if (Armadillo_FOUND)
message(STATUS "Found Armadillo config at: ${Armadillo_DIR}")
add_compile_options(-DARMA_DONT_USE_WRAPPER)
set(AUTOPPL_INCLUDE_DIRS ${AUTOPPL_INCLUDE_DIRS} ${ARMADILLO_INCLUDE_DIRS})
set(AUTOPPL_LIBS ${AUTOPPL_LIBS} ${ARMADILLO_LIBRARIES})
endif()
# Find Eigen3
find_package(Eigen3 3.3 CONFIG REQUIRED NO_MODULE
HINTS ${CMAKE_CURRENT_SOURCE_DIR}/lib/FastAD/libs/eigen-3.3.7/build/share)
set(AUTOPPL_LIBS ${AUTOPPL_LIBS} Eigen3::Eigen)
message(STATUS "Eigen3 found at ${EIGEN3_INCLUDE_DIR}")

# Find FastAD
find_package(FastAD CONFIG REQUIRED
Expand All @@ -50,6 +30,57 @@ if (FastAD_FOUND)
set(AUTOPPL_LIBS ${AUTOPPL_LIBS} FastAD::FastAD)
endif()

# Add this library as interface (header-only)
add_library(${PROJECT_NAME} INTERFACE)
target_include_directories(${PROJECT_NAME}
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
$<INSTALL_INTERFACE:${CMAKE_INSTALL_INCLUDEDIR}>)
target_compile_features(${PROJECT_NAME} INTERFACE cxx_std_17)

# Set install destinations
install(TARGETS ${PROJECT_NAME}
EXPORT ${PROJECT_NAME}_Targets
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR}
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR})

# Create AutoPPLConfigVersion.cmake which contains current project version
# This is supposed to help with (major) version compatibility.
include(CMakePackageConfigHelpers)
write_basic_package_version_file("${PROJECT_NAME}ConfigVersion.cmake"
VERSION ${PROJECT_VERSION}
COMPATIBILITY SameMajorVersion)
configure_package_config_file(
"${PROJECT_SOURCE_DIR}/cmake/${PROJECT_NAME}Config.cmake.in"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
INSTALL_DESTINATION
${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)

install(EXPORT ${PROJECT_NAME}_Targets
FILE ${PROJECT_NAME}Targets.cmake
NAMESPACE ${PROJECT_NAME}::
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)

install(FILES
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}Config.cmake"
"${PROJECT_BINARY_DIR}/${PROJECT_NAME}ConfigVersion.cmake"
DESTINATION ${CMAKE_INSTALL_DATAROOTDIR}/${PROJECT_NAME}/cmake)

install(DIRECTORY ${PROJECT_SOURCE_DIR}/include DESTINATION ${CMAKE_INSTALL_PREFIX})

# Automate the choosing of config
if (NOT CMAKE_BUILD_TYPE)
# if binary directory ends with "release", use release mode
if (${PROJECT_BINARY_DIR} MATCHES "release$")
set(CMAKE_BUILD_TYPE RELEASE)
add_compile_options(-O3)
# otherwise, use debug mode
else()
set(CMAKE_BUILD_TYPE DEBUG)
endif()
endif()
message(STATUS "Compiling in ${CMAKE_BUILD_TYPE} mode")

# Set directory for GoogleTest
set(GTEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/benchmark/googletest/googletest)
set(GBENCH_DIR ${CMAKE_CURRENT_SOURCE_DIR}/lib/benchmark)
Expand Down