Merge branch 'master' into cereal

Signed-off-by: Omar Shrit <omar@shrit.me>
This commit is contained in:
Omar Shrit
2020-09-17 16:05:03 +02:00
10 changed files with 84 additions and 73 deletions
+2 -2
View File
@@ -14,9 +14,9 @@ if (GO_EXECUTABLE)
RESULT_VARIABLE RESULT
)
if (RESULT EQUAL 0)
string(REGEX REPLACE ".*([0-9]+\\.[0-9]+\\.[0-9]+).*" "\\1"
string(REGEX REPLACE ".*([0-9]+\\.[0-9]+\(\\.[0-9]+\)?).*" "\\1"
GO_VERSION_STRING ${GO_VERSION_STRING})
endif()
endif()
endif()
include(FindPackageHandleStandardArgs)
+1
View File
@@ -132,6 +132,7 @@ Copyright:
Copyright 2020, Lakshya Ojha <ojhalakshya@gmail.com>
Copyright 2020, Bisakh Mondal <bisakhmondal00@gmail.com>
Copyright 2020, Benson Muite <benson_muite@emailplus.org>
Copyright 2020, Sarthak Bhardwaj <7sarthakbhardwaj@gmail.com>
License: BSD-3-clause
All rights reserved.
+3 -3
View File
@@ -100,8 +100,8 @@ installed through apt:
@code
# apt-get install libboost-math-dev libboost-test-dev libcereal-dev
libarmadillo-dev binutils-dev python-pandas python-numpy cython
python-setuptools
libarmadillo-dev binutils-dev python3-pandas python3-numpy cython3
python3-setuptools
@endcode
If you are using Ubuntu 19.10 or newer, you can also install @c libensmallen-dev
@@ -123,7 +123,7 @@ On Fedora, Red Hat, or CentOS, these same dependencies can be obtained via dnf:
@code
# dnf install boost-devel boost-test boost-math armadillo-devel binutils-devel
python2-Cython python2-setuptools python2-numpy python2-pandas ensmallen-devel
python3-Cython python3-setuptools python3-numpy python3-pandas ensmallen-devel
stbi-devel cereal-devel
@endcode
+3 -62
View File
@@ -125,68 +125,9 @@ string(REGEX REPLACE ".*#define MLPACK_VERSION_PATCH [\"]?([0-9x]+)[\"]?.*"
set(PACKAGE_VERSION
"${MLPACK_VERSION_MAJOR}.${MLPACK_VERSION_MINOR}.${MLPACK_VERSION_PATCH}")
# If we are building Python bindings, we have to configure setup.py but only
# after we've recursed into methods/.
if (BUILDING_PYTHON_BINDINGS)
get_property(CYTHON_INCLUDE_DIRECTORIES DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
PROPERTY INCLUDE_DIRECTORIES)
add_custom_target(python_configure
COMMAND ${CMAKE_COMMAND}
-D SETUP_PY_IN=${CMAKE_SOURCE_DIR}/src/mlpack/bindings/python/setup.py.in
-D SETUP_PY_OUT=${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/setup.py
-D PACKAGE_VERSION="${PACKAGE_VERSION}"
-D Boost_SERIALIZATION_LIBRARY="${Boost_SERIALIZATION_LIBRARY_RELEASE}"
-D Boost_LIBRARY_DIRS="${Boost_LIBRARY_DIRS}"
-D ARMADILLO_LIBRARIES="${ARMADILLO_LIBRARIES}"
-D MLPACK_LIBRARY=$<TARGET_LINKER_FILE:mlpack>
-D MLPACK_LIBDIR=$<TARGET_LINKER_FILE_DIR:mlpack>
-D MLPACK_PYXS="${MLPACK_PYXS}"
-D OpenMP_CXX_FLAGS="${OpenMP_CXX_FLAGS}"
-D DISABLE_CFLAGS="${DISABLE_CFLAGS}"
-D CYTHON_INCLUDE_DIRECTORIES="${CYTHON_INCLUDE_DIRECTORIES}"
-D CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-D OUTPUT_DIR=${CMAKE_BINARY_DIR}
-P "${CMAKE_SOURCE_DIR}/src/mlpack/bindings/python/ConfigureSetup.cmake"
BYPRODUCTS "${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/setup.py"
COMMENT "Configuring setup.py...")
add_dependencies(python_configure python_copy)
add_dependencies(python_configured python_configure)
# Append the package version to __init__.py after all the imports are loaded.
file(APPEND ${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/mlpack/__init__.py
"__version__='${PACKAGE_VERSION}'\n")
endif ()
# If we are building Julia bindings, we have to end the 'module' declaration in
# mlpack.jl
if (BUILD_JULIA_BINDINGS)
file(APPEND
"${CMAKE_BINARY_DIR}/src/mlpack/bindings/julia/mlpack/src/mlpack.jl"
"\nend\ninclude(\"functions.jl\")\ninclude(\"serialization.jl\")\nend\n")
endif ()
# If we are building Go bindings, we have to end the 'module' declaration in
# models.go
if (BUILD_GO_BINDINGS)
file(APPEND
"${CMAKE_BINARY_DIR}/src/mlpack/bindings/go/src/mlpack.org/v1/mlpack/models.go"
"*/\n"
"import \"C\"\n\n"
"import (\n"
" \"runtime\"\n"
" \"unsafe\"\n"
")\n\n")
include("${CMAKE_SOURCE_DIR}/CMake/go/AppendModel.cmake")
# Read list content.
get_property(MODELS GLOBAL PROPERTY GO_MODELS)
foreach (models IN LISTS MODELS)
append_model(
"${CMAKE_BINARY_DIR}/src/mlpack/bindings/go/src/mlpack.org/v1/mlpack/models.go"
${models})
endforeach()
endif()
post_python_bindings()
post_julia_setup()
post_go_setup()
# If we are building R-bindings, we have to run some setup after we
# recurse into methods/. If not, this macro is empty.
+1 -1
View File
@@ -691,7 +691,7 @@ class CallForVersion : public Success {
: CallForVersion("This should be caught in your main function, see examples", ExitCodes::Success) {}
};
/// Does not output a diagnostic in CLI11_PARSE, but allows to return from main() with a specific error code.
/// Does not output a diagnostic in CLI11_PARSE, but allows main() to return with a specific error code.
class RuntimeError : public ParseError {
CLI11_ERROR_DEF(ParseError, RuntimeError)
explicit RuntimeError(int exit_code = 1) : RuntimeError("Runtime error", exit_code) {}
+24 -1
View File
@@ -9,6 +9,29 @@ macro (not_found_return message)
endif()
endmacro ()
macro (post_go_setup)
if (BUILD_GO_BINDINGS)
# Once `GO_MODELS` is populated, generate `models.go`.
file(APPEND
"${CMAKE_BINARY_DIR}/src/mlpack/bindings/go/src/mlpack.org/v1/mlpack/models.go"
"*/\n"
"import \"C\"\n\n"
"import (\n"
" \"runtime\"\n"
" \"unsafe\"\n"
")\n\n")
include("${CMAKE_SOURCE_DIR}/CMake/go/AppendModel.cmake")
# Read list content.
get_property(MODELS GLOBAL PROPERTY GO_MODELS)
foreach (models IN LISTS MODELS)
append_model(
"${CMAKE_BINARY_DIR}/src/mlpack/bindings/go/src/mlpack.org/v1/mlpack/models.go"
${models})
endforeach()
endif()
endmacro ()
# If we are not supposed to make Go bindings, define the macro so it does
# nothing and leave this file.
if (NOT BUILD_GO_BINDINGS)
@@ -176,7 +199,7 @@ set_property(GLOBAL PROPERTY GO_MODELS "")
macro (add_go_binding name)
if (BUILD_GO_BINDINGS)
# Include all .h that define model to models.go.
# Include all .h that define model to models.go.
file(READ "${CMAKE_CURRENT_SOURCE_DIR}/${name}_main.cpp" MAIN_FILE)
if (MAIN_FILE MATCHES "PARAM_MODEL")
file(APPEND
+10
View File
@@ -7,6 +7,16 @@ macro (not_found_return message)
return()
endmacro ()
macro (post_julia_setup)
# If we are building Julia bindings, we have to end the 'module' declaration in
# mlpack.jl.
if (BUILD_JULIA_BINDINGS)
file(APPEND
"${CMAKE_BINARY_DIR}/src/mlpack/bindings/julia/mlpack/src/mlpack.jl"
"\nend\ninclude(\"functions.jl\")\ninclude(\"serialization.jl\")\nend\n")
endif ()
endmacro ()
# If we are not supposed to make Julia bindings, define the macro so it does
# nothing and leave this file.
if (NOT BUILD_JULIA_BINDINGS)
+34
View File
@@ -7,6 +7,40 @@ macro (not_found_return message)
return()
endmacro ()
macro (post_python_bindings)
# If we are building Python bindings, we have to configure setup.py but only
# after we've recursed into methods/.
if (BUILDING_PYTHON_BINDINGS)
get_property(CYTHON_INCLUDE_DIRECTORIES DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}
PROPERTY INCLUDE_DIRECTORIES)
add_custom_target(python_configure
COMMAND ${CMAKE_COMMAND}
-D SETUP_PY_IN=${CMAKE_SOURCE_DIR}/src/mlpack/bindings/python/setup.py.in
-D SETUP_PY_OUT=${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/setup.py
-D PACKAGE_VERSION="${PACKAGE_VERSION}"
-D Boost_SERIALIZATION_LIBRARY="${Boost_SERIALIZATION_LIBRARY_RELEASE}"
-D Boost_LIBRARY_DIRS="${Boost_LIBRARY_DIRS}"
-D ARMADILLO_LIBRARIES="${ARMADILLO_LIBRARIES}"
-D MLPACK_LIBRARY=$<TARGET_LINKER_FILE:mlpack>
-D MLPACK_LIBDIR=$<TARGET_LINKER_FILE_DIR:mlpack>
-D MLPACK_PYXS="${MLPACK_PYXS}"
-D OpenMP_CXX_FLAGS="${OpenMP_CXX_FLAGS}"
-D DISABLE_CFLAGS="${DISABLE_CFLAGS}"
-D CYTHON_INCLUDE_DIRECTORIES="${CYTHON_INCLUDE_DIRECTORIES}"
-D CMAKE_CXX_FLAGS=${CMAKE_CXX_FLAGS}
-D OUTPUT_DIR=${CMAKE_BINARY_DIR}
-P "${CMAKE_SOURCE_DIR}/src/mlpack/bindings/python/ConfigureSetup.cmake"
BYPRODUCTS "${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/setup.py"
COMMENT "Configuring setup.py...")
add_dependencies(python_configure python_copy)
add_dependencies(python_configured python_configure)
# Append the package version to __init__.py after all the imports are loaded.
file(APPEND ${CMAKE_BINARY_DIR}/src/mlpack/bindings/python/mlpack/__init__.py
"__version__='${PACKAGE_VERSION}'\n")
endif ()
endmacro ()
# If we are not supposed to make Python bindings, define the macro so it does
# nothing and leave this file.
if (NOT BUILD_PYTHON_BINDINGS)
+4 -2
View File
@@ -23,10 +23,12 @@ CVBase<MLAlgorithm,
MatType,
PredictionsType,
WeightsType>::CVBase() :
isDatasetInfoPassed(false)
isDatasetInfoPassed(false),
numClasses(0)
{
static_assert(!MIE::TakesNumClasses,
"The given MLAlgorithm requires the numClasses parameter");
"The given MLAlgorithm requires the numClasses parameter; "
"make sure that you pass numClasses with type size_t!");
}
template<typename MLAlgorithm,
@@ -86,8 +86,8 @@ BINDING_EXAMPLE(
"predictions", "test_predictions") +
"\n\n"
"Because the estimator computes a predictive distribution instead of "
"simple point estimate, the " + PRINT_PARAM_STRING("stds") + " parameter "
"allows to save the prediction uncertainties: "
"a simple point estimate, the " + PRINT_PARAM_STRING("stds") + " parameter "
"allows one to save the prediction uncertainties: "
"\n\n" +
PRINT_CALL("bayesian_linear_regression", "input_model",
"blr_model", "test", "test",