"git@developer.sourcefind.cn:OpenDAS/apex.git" did not exist on "197bcc4893e9489025b63e23784c8c1ce02d779d"
Commit 3a91295e authored by Joachim's avatar Joachim
Browse files

Merge branch 'master' of https://github.com/davisking/dlib

parents 22164e5d 75f66582
version: "{build}"
configuration: Release
build_script:
# build test
- mkdir %APPVEYOR_BUILD_FOLDER%\build_test
- cd %APPVEYOR_BUILD_FOLDER%\build_test
- cmake -G "Visual Studio 14 2015 Win64" ../dlib/test
- cmake --build . --config %CONFIGURATION%
test_script:
# run test
- cd %APPVEYOR_BUILD_FOLDER%\build_test\%CONFIGURATION%
- dtest --runall
......@@ -7,6 +7,9 @@
cmake_minimum_required(VERSION 2.8.12)
project(dlib)
# Adhere to GNU filesystem layout conventions
include(GNUInstallDirs)
# default to a Release build (except if CMAKE_BUILD_TYPE is set)
include(cmake_utils/release_build_by_default)
include(cmake_utils/use_cpp_11.cmake)
......@@ -178,6 +181,9 @@ if (NOT TARGET dlib)
)
set(dlib_needed_libraries)
set(dlib_needed_includes)
if (DLIB_ISO_CPP_ONLY)
add_library(dlib STATIC ${source_files} )
if (UNIX AND NOT DLIB_IN_PROJECT_BUILD)
......@@ -216,8 +222,6 @@ if (NOT TARGET dlib)
stack_trace.cpp
)
set(dlib_needed_libraries)
set(dlib_needed_includes)
if(UNIX)
set(CMAKE_THREAD_PREFER_PTHREAD ON)
find_package(Threads REQUIRED)
......@@ -596,7 +600,7 @@ if (NOT TARGET dlib)
endif()
endif()
if (CUDA_FOUND AND cudnn AND cudnn_include AND COMPILER_CAN_DO_CPP_11 AND cuda_test_compile_worked AND cudnn_test_compile_worked)
if (CUDA_FOUND AND cudnn AND COMPILER_CAN_DO_CPP_11 AND cuda_test_compile_worked AND cudnn_test_compile_worked AND cudnn_include)
set(source_files ${source_files}
dnn/cuda_dlib.cu
dnn/cudnn_dlibapi.cpp
......@@ -670,17 +674,6 @@ if (NOT TARGET dlib)
else()
add_library(dlib STATIC ${source_files} )
endif()
target_include_directories(dlib
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
INTERFACE $<INSTALL_INTERFACE:include>
PUBLIC ${dlib_needed_includes}
)
target_link_libraries(dlib PRIVATE ${dlib_needed_libraries})
if (DLIB_IN_PROJECT_BUILD)
target_compile_options(dlib PUBLIC ${active_preprocessor_switches})
else()
target_compile_options(dlib PRIVATE ${active_preprocessor_switches})
endif()
if (UNIX AND NOT DLIB_IN_PROJECT_BUILD)
if (DLIB_USE_CUDA)
cuda_add_library(dlib_shared SHARED ${source_files} )
......@@ -689,17 +682,33 @@ if (NOT TARGET dlib)
add_library(dlib_shared SHARED ${source_files} )
add_dependencies(dlib_shared dlib)
endif()
target_include_directories(dlib_shared
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
INTERFACE $<INSTALL_INTERFACE:include>
PUBLIC ${dlib_needed_includes}
)
target_link_libraries(dlib_shared PRIVATE ${dlib_needed_libraries})
target_compile_options(dlib_shared PRIVATE ${active_preprocessor_switches})
endif()
endif () ##### end of if NOT DLIB_ISO_CPP_ONLY ##########################################################
target_include_directories(dlib
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
INTERFACE $<INSTALL_INTERFACE:include>
PUBLIC ${dlib_needed_includes}
)
target_link_libraries(dlib PRIVATE ${dlib_needed_libraries})
if (DLIB_IN_PROJECT_BUILD)
target_compile_options(dlib PUBLIC ${active_preprocessor_switches})
else()
target_compile_options(dlib PRIVATE ${active_preprocessor_switches})
endif()
if (UNIX AND NOT DLIB_IN_PROJECT_BUILD)
target_include_directories(dlib_shared
INTERFACE $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/..>
INTERFACE $<INSTALL_INTERFACE:include>
PUBLIC ${dlib_needed_includes}
)
target_link_libraries(dlib_shared PRIVATE ${dlib_needed_libraries})
target_compile_options(dlib_shared PRIVATE ${active_preprocessor_switches})
endif()
# Allow the unit tests to ask us to compile the all/source.cpp file just to make sure it compiles.
if (DLIB_TEST_COMPILE_ALL_SOURCE_CPP)
ADD_LIBRARY(dlib_all_source_cpp STATIC all/source.cpp)
......@@ -709,7 +718,6 @@ if (NOT TARGET dlib)
# Install the library
if (NOT DLIB_IN_PROJECT_BUILD)
set (LIB_INSTALL_DIR lib CACHE STRING "Install location of libraries (e.g. lib32 or lib64 for multilib installations)")
cmake_minimum_required(VERSION 2.8.8)
if(UNIX)
set_target_properties(dlib_shared PROPERTIES
......@@ -717,39 +725,36 @@ if (NOT TARGET dlib)
VERSION ${VERSION})
install(TARGETS dlib dlib_shared
EXPORT dlib
RUNTIME DESTINATION bin # Windows (including cygwin) considers .dll to be runtime artifacts
LIBRARY DESTINATION "${LIB_INSTALL_DIR}"
ARCHIVE DESTINATION "${LIB_INSTALL_DIR}")
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # Windows (including cygwin) considers .dll to be runtime artifacts
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
else()
install(TARGETS dlib
EXPORT dlib
RUNTIME DESTINATION bin # Windows considers .dll to be runtime artifacts
LIBRARY DESTINATION lib
ARCHIVE DESTINATION lib)
RUNTIME DESTINATION ${CMAKE_INSTALL_BINDIR} # Windows considers .dll to be runtime artifacts
LIBRARY DESTINATION ${CMAKE_INSTALL_LIBDIR}
ARCHIVE DESTINATION ${CMAKE_INSTALL_LIBDIR})
endif()
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION include/dlib
install(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}/ DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dlib
FILES_MATCHING PATTERN "*.h" PATTERN "*.cmake"
REGEX "${CMAKE_CURRENT_BINARY_DIR}" EXCLUDE)
configure_file(${PROJECT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
# overwrite config.h with the configured one
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h DESTINATION include/dlib)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/config.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dlib)
configure_file(${PROJECT_SOURCE_DIR}/revision.h.in ${CMAKE_CURRENT_BINARY_DIR}/revision.h)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/revision.h DESTINATION include/dlib)
install(FILES "LICENSE.txt" DESTINATION share/doc/dlib)
install(FILES ${CMAKE_CURRENT_BINARY_DIR}/revision.h DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}/dlib)
## Config.cmake generation and installation
set(ConfigPackageLocation "${LIB_INSTALL_DIR}/cmake/dlib")
set(ConfigPackageLocation "${CMAKE_INSTALL_LIBDIR}/cmake/dlib")
install(EXPORT dlib
NAMESPACE dlib::
DESTINATION ${ConfigPackageLocation})
set(CONF_INSTALL_PATH "\${dlib_CMAKE_DIR}/../../../")
configure_file(cmake_utils/dlibConfig.cmake.in "${CMAKE_CURRENT_BINARY_DIR}/config/dlibConfig.cmake" @ONLY)
include(CMakePackageConfigHelpers)
......@@ -768,7 +773,7 @@ if (NOT TARGET dlib)
configure_file("cmake_utils/dlib.pc.in" "dlib-1.pc" @ONLY)
install(FILES "${CMAKE_CURRENT_BINARY_DIR}/dlib-1.pc"
DESTINATION "${LIB_INSTALL_DIR}/pkgconfig")
DESTINATION "${CMAKE_INSTALL_LIBDIR}/pkgconfig")
endif()
......
......@@ -4,7 +4,9 @@
#define DLIB_AnY_H_
#include "any_abstract.h"
#include "../smart_pointers.h"
#include "../algs.h"
#include <memory>
#include <typeinfo>
namespace dlib
......@@ -136,7 +138,7 @@ namespace dlib
virtual ~base() {}
virtual void copy_to (
scoped_ptr<base>& dest
std::unique_ptr<base>& dest
) const = 0;
};
......@@ -148,14 +150,14 @@ namespace dlib
derived(const T& val) : item(val) {}
virtual void copy_to (
scoped_ptr<base>& dest
std::unique_ptr<base>& dest
) const
{
dest.reset(new derived<T>(item));
}
};
scoped_ptr<base> data;
std::unique_ptr<base> data;
};
// ----------------------------------------------------------------------------------------
......
......@@ -4,7 +4,6 @@
#define DLIB_AnY_DECISION_FUNCTION_Hh_
#include "any.h"
#include "../smart_pointers.h"
#include "any_decision_function_abstract.h"
......@@ -148,7 +147,7 @@ namespace dlib
virtual ~base() {}
virtual void copy_to (
scoped_ptr<base>& dest
std::unique_ptr<base>& dest
) const = 0;
virtual result_type evaluate (
......@@ -164,7 +163,7 @@ namespace dlib
derived(const T& val) : item(val) {}
virtual void copy_to (
scoped_ptr<base>& dest
std::unique_ptr<base>& dest
) const
{
dest.reset(new derived<T>(item));
......@@ -178,7 +177,7 @@ namespace dlib
}
};
scoped_ptr<base> data;
std::unique_ptr<base> data;
};
// ----------------------------------------------------------------------------------------
......
......@@ -4,7 +4,6 @@
#define DLIB_AnY_FUNCTION_Hh_
#include "any.h"
#include "../smart_pointers.h"
#include "any_function_abstract.h"
......
......@@ -166,7 +166,7 @@ struct Tbase
{
virtual ~Tbase() {}
virtual result_type evaluate () const = 0;
virtual void copy_to ( scoped_ptr<Tbase>& dest) const = 0;
virtual void copy_to ( std::unique_ptr<Tbase>& dest) const = 0;
};
template <
......@@ -177,7 +177,7 @@ struct Tbase<T (A1)>
{
virtual ~Tbase() {}
virtual T evaluate ( A1) const = 0;
virtual void copy_to ( scoped_ptr<Tbase>& dest) const = 0;
virtual void copy_to ( std::unique_ptr<Tbase>& dest) const = 0;
};
template <
......@@ -188,7 +188,7 @@ struct Tbase<T (A1,A2)>
{
virtual ~Tbase() {}
virtual T evaluate (A1,A2) const = 0;
virtual void copy_to ( scoped_ptr<Tbase>& dest) const = 0;
virtual void copy_to ( std::unique_ptr<Tbase>& dest) const = 0;
};
template <
......@@ -199,7 +199,7 @@ struct Tbase<T (A1,A2,A3)>
{
virtual ~Tbase() {}
virtual T evaluate (A1,A2,A3) const = 0;
virtual void copy_to ( scoped_ptr<Tbase>& dest) const = 0;
virtual void copy_to ( std::unique_ptr<Tbase>& dest) const = 0;
};
template <
......@@ -211,7 +211,7 @@ struct Tbase<T (A1,A2,A3,A4)>
{
virtual ~Tbase() {}
virtual T evaluate (A1,A2,A3,A4) const = 0;
virtual void copy_to ( scoped_ptr<Tbase>& dest) const = 0;
virtual void copy_to ( std::unique_ptr<Tbase>& dest) const = 0;
};
template <
......@@ -223,7 +223,7 @@ struct Tbase<T (A1,A2,A3,A4,A5)>
{
virtual ~Tbase() {}
virtual T evaluate (A1,A2,A3,A4,A5) const = 0;
virtual void copy_to ( scoped_ptr<Tbase>& dest) const = 0;
virtual void copy_to ( std::unique_ptr<Tbase>& dest) const = 0;
};
template <
......@@ -235,7 +235,7 @@ struct Tbase<T (A1,A2,A3,A4,A5,A6)>
{
virtual ~Tbase() {}
virtual T evaluate (A1,A2,A3,A4,A5,A6) const = 0;
virtual void copy_to ( scoped_ptr<Tbase>& dest) const = 0;
virtual void copy_to ( std::unique_ptr<Tbase>& dest) const = 0;
};
template <
......@@ -248,7 +248,7 @@ struct Tbase<T (A1,A2,A3,A4,A5,A6,A7)>
{
virtual ~Tbase() {}
virtual T evaluate (A1,A2,A3,A4,A5,A6,A7) const = 0;
virtual void copy_to ( scoped_ptr<Tbase>& dest) const = 0;
virtual void copy_to ( std::unique_ptr<Tbase>& dest) const = 0;
};
template <
......@@ -261,7 +261,7 @@ struct Tbase<T (A1,A2,A3,A4,A5,A6,A7,A8)>
{
virtual ~Tbase() {}
virtual T evaluate (A1,A2,A3,A4,A5,A6,A7,A8) const = 0;
virtual void copy_to ( scoped_ptr<Tbase>& dest) const = 0;
virtual void copy_to ( std::unique_ptr<Tbase>& dest) const = 0;
};
template <
......@@ -274,7 +274,7 @@ struct Tbase<T (A1,A2,A3,A4,A5,A6,A7,A8,A9)>
{
virtual ~Tbase() {}
virtual T evaluate (A1,A2,A3,A4,A5,A6,A7,A8,A9) const = 0;
virtual void copy_to ( scoped_ptr<Tbase>& dest) const = 0;
virtual void copy_to ( std::unique_ptr<Tbase>& dest) const = 0;
};
template <
......@@ -288,7 +288,7 @@ struct Tbase<T (A1,A2,A3,A4,A5,A6,A7,A8,A9,A10)>
{
virtual ~Tbase() {}
virtual T evaluate (A1,A2,A3,A4,A5,A6,A7,A8,A9,A10) const = 0;
virtual void copy_to ( scoped_ptr<Tbase>& dest) const = 0;
virtual void copy_to ( std::unique_ptr<Tbase>& dest) const = 0;
};
typedef Tbase<function_type> base;
......@@ -318,7 +318,7 @@ static typename disable_if<is_function<T>,const T&>::type deref (const U& item)
typename funct_type<T>::type item; \
derived() {} \
derived(const T& val) : item(copy(val)) {} \
virtual void copy_to ( scoped_ptr<base>& dest) const \
virtual void copy_to ( std::unique_ptr<base>& dest) const \
{ dest.reset(new derived(deref<T>(item))); }
template <typename T, typename FT>
......@@ -508,7 +508,7 @@ struct derived<T,result_type (A1,A2,A3,A4,A5,A6,A7,A8,A9,A10)> : public base
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
};
scoped_ptr<base> data;
std::unique_ptr<base> data;
#undef DLIB_ANY_FUNCTION_DERIVED_BOILERPLATE
......
......@@ -4,7 +4,6 @@
#define DLIB_AnY_TRAINER_H_
#include "any.h"
#include "../smart_pointers.h"
#include "any_decision_function.h"
......@@ -157,7 +156,7 @@ namespace dlib
) const = 0;
virtual void copy_to (
scoped_ptr<base>& dest
std::unique_ptr<base>& dest
) const = 0;
};
......@@ -169,7 +168,7 @@ namespace dlib
derived(const T& val) : item(val) {}
virtual void copy_to (
scoped_ptr<base>& dest
std::unique_ptr<base>& dest
) const
{
dest.reset(new derived<T>(item));
......@@ -184,7 +183,7 @@ namespace dlib
}
};
scoped_ptr<base> data;
std::unique_ptr<base> data;
};
// ----------------------------------------------------------------------------------------
......
......@@ -5,6 +5,11 @@
#include "bayes_utils_abstract.h"
#include <algorithm>
#include <ctime>
#include <memory>
#include <vector>
#include "../string.h"
#include "../map.h"
#include "../matrix.h"
......@@ -13,11 +18,7 @@
#include "../set.h"
#include "../algs.h"
#include "../noncopyable.h"
#include "../smart_pointers.h"
#include "../graph.h"
#include <vector>
#include <algorithm>
#include <ctime>
namespace dlib
{
......@@ -1659,7 +1660,7 @@ namespace dlib
private:
scoped_ptr<bayesian_network_join_tree_helpers::bnjt> impl;
std::unique_ptr<bayesian_network_join_tree_helpers::bnjt> impl;
unsigned long num_nodes;
};
......
......@@ -3,17 +3,19 @@
#ifndef DLIB_BRIDGe_Hh_
#define DLIB_BRIDGe_Hh_
#include "bridge_abstract.h"
#include <iostream>
#include <memory>
#include <string>
#include "bridge_abstract.h"
#include "../pipe.h"
#include "../threads.h"
#include "../smart_pointers.h"
#include "../serialize.h"
#include "../sockets.h"
#include "../sockstreambuf.h"
#include "../logger.h"
#include "../algs.h"
#include <iostream>
namespace dlib
{
......@@ -545,8 +547,8 @@ namespace dlib
signaler s;
bool receive_thread_active;
bool transmit_thread_active;
scoped_ptr<connection> con;
scoped_ptr<listener> list;
std::unique_ptr<connection> con;
std::unique_ptr<listener> list;
const unsigned short port;
const std::string ip;
transmit_pipe_type* const transmit_pipe;
......@@ -656,7 +658,7 @@ namespace dlib
private:
scoped_ptr<impl_brns::impl_bridge_base> pimpl;
std::unique_ptr<impl_brns::impl_bridge_base> pimpl;
};
// ----------------------------------------------------------------------------------------
......
......@@ -4,6 +4,7 @@
#define DLIB_BSP_CPph_
#include "bsp.h"
#include <memory>
#include <stack>
// ----------------------------------------------------------------------------------------
......@@ -24,7 +25,7 @@ namespace dlib
cons.clear();
for (unsigned long i = 0; i < hosts.size(); ++i)
{
scoped_ptr<bsp_con> con(new bsp_con(hosts[i]));
std::unique_ptr<bsp_con> con(new bsp_con(hosts[i]));
dlib::serialize(node_id, con->stream); // tell the other end our node_id
unsigned long id = i+1;
cons.add(id, con);
......@@ -43,7 +44,7 @@ namespace dlib
{
try
{
scoped_ptr<bsp_con> con(new bsp_con(hosts[i].addr));
std::unique_ptr<bsp_con> con(new bsp_con(hosts[i].addr));
dlib::serialize(node_id, con->stream); // tell the other end our node_id
con->stream.flush();
unsigned long id = hosts[i].node_id;
......@@ -316,7 +317,7 @@ namespace dlib
_cons.reset();
while (_cons.move_next())
{
scoped_ptr<thread_function> ptr(new thread_function(&impl2::read_thread,
std::unique_ptr<thread_function> ptr(new thread_function(&impl2::read_thread,
_cons.element().value().get(),
_node_id,
_cons.element().key(),
......@@ -330,7 +331,7 @@ namespace dlib
bool bsp_context::
receive_data (
shared_ptr<std::vector<char> >& item,
std::shared_ptr<std::vector<char> >& item,
unsigned long& sending_node_id
)
{
......
......@@ -4,17 +4,19 @@
#define DLIB_BsP_Hh_
#include "bsp_abstract.h"
#include <memory>
#include <queue>
#include <vector>
#include "../sockets.h"
#include "../array.h"
#include "../smart_pointers.h"
#include "../sockstreambuf.h"
#include "../string.h"
#include "../serialize.h"
#include "../map.h"
#include "../ref.h"
#include "../vectorstream.h"
#include <queue>
#include <vector>
namespace dlib
{
......@@ -41,7 +43,7 @@ namespace dlib
}
bsp_con(
scoped_ptr<connection>& conptr
std::unique_ptr<connection>& conptr
) :
buf(conptr),
stream(&buf),
......@@ -53,13 +55,13 @@ namespace dlib
con->disable_nagle();
}
scoped_ptr<connection> con;
std::unique_ptr<connection> con;
sockstreambuf buf;
std::iostream stream;
bool terminated;
};
typedef dlib::map<unsigned long, scoped_ptr<bsp_con> >::kernel_1a_c map_id_to_con;
typedef dlib::map<unsigned long, std::unique_ptr<bsp_con> >::kernel_1a_c map_id_to_con;
void connect_all (
map_id_to_con& cons,
......@@ -134,7 +136,7 @@ namespace dlib
)
{
cons.clear();
scoped_ptr<listener> list;
std::unique_ptr<listener> list;
const int status = create_listener(list, port);
if (status == PORTINUSE)
{
......@@ -148,13 +150,13 @@ namespace dlib
port_notify_function(list->get_listening_port());
scoped_ptr<connection> con;
std::unique_ptr<connection> con;
if (list->accept(con))
{
throw socket_error("Error occurred while accepting new connection");
}
scoped_ptr<bsp_con> temp(new bsp_con(con));
std::unique_ptr<bsp_con> temp(new bsp_con(con));
unsigned long remote_node_id;
dlib::deserialize(remote_node_id, temp->stream);
......@@ -197,7 +199,7 @@ namespace dlib
while (cons2.size() > 0)
{
unsigned long id;
scoped_ptr<bsp_con> temp;
std::unique_ptr<bsp_con> temp;
cons2.remove_any(id,temp);
cons.add(id,temp);
}
......@@ -207,7 +209,7 @@ namespace dlib
struct msg_data
{
shared_ptr<std::vector<char> > data;
std::shared_ptr<std::vector<char> > data;
unsigned long sender_id;
char msg_type;
dlib::uint64 epoch;
......@@ -420,7 +422,7 @@ namespace dlib
)
{
unsigned long id;
shared_ptr<std::vector<char> > temp;
std::shared_ptr<std::vector<char> > temp;
if (receive_data(temp,id))
throw dlib::socket_error("Call to bsp_context::receive() got an unexpected message.");
}
......@@ -459,7 +461,7 @@ namespace dlib
unsigned long& sending_node_id
)
{
shared_ptr<std::vector<char> > temp;
std::shared_ptr<std::vector<char> > temp;
if (receive_data(temp, sending_node_id))
{
vectorstream sin(*temp);
......@@ -496,7 +498,7 @@ namespace dlib
!*/
bool receive_data (
shared_ptr<std::vector<char> >& item,
std::shared_ptr<std::vector<char> >& item,
unsigned long& sending_node_id
);
......@@ -533,7 +535,7 @@ namespace dlib
impl1::map_id_to_con& _cons;
const unsigned long _node_id;
array<scoped_ptr<thread_function> > threads;
array<std::unique_ptr<thread_function> > threads;
// -----------------------------------
......
prefix=@CMAKE_INSTALL_PREFIX@
exec_prefix=${prefix}
libdir=${exec_prefix}/@LIB_INSTALL_DIR@
includedir=${prefix}/include
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
Name: @PROJECT_NAME@
Description: Numerical and networking C++ library
......
......@@ -19,24 +19,18 @@
# ===================================================================================
# Compute paths
get_filename_component(dlib_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
if(${CMAKE_MAJOR_VERSION}.${CMAKE_MINOR_VERSION} VERSION_LESS 2.8)
get_filename_component(dlib_INSTALL_PATH "@CONF_INSTALL_PATH@" ABSOLUTE)
else()
get_filename_component(dlib_INSTALL_PATH "@CONF_INSTALL_PATH@" REALPATH)
endif()
set(dlib_INCLUDE_DIRS "${dlib_INSTALL_PATH}/include" "@dlib_needed_includes@")
# Our library dependencies (contains definitions for IMPORTED targets)
if(NOT TARGET dlib-shared AND NOT dlib_BINARY_DIR)
include("${dlib_CMAKE_DIR}/dlib.cmake")
# Compute paths
get_filename_component(dlib_CMAKE_DIR "${CMAKE_CURRENT_LIST_FILE}" PATH)
include("${dlib_CMAKE_DIR}/dlib.cmake")
endif()
find_library(dlib_LIBRARIES dlib HINTS ${dlib_INSTALL_PATH}/lib)
find_library(dlib_LIBRARIES dlib HINTS "@CMAKE_INSTALL_FULL_LIBDIR@")
set(dlib_LIBRARIES ${dlib_LIBRARIES} "@dlib_needed_libraries@")
set(dlib_LIBS ${dlib_LIBRARIES} "@dlib_needed_libraries@")
set(dlib_INCLUDE_DIRS "@CMAKE_INSTALL_FULL_INCLUDEDIR@" "@dlib_needed_includes@")
include(${dlib_INSTALL_PATH}/include/dlib/cmake_utils/use_cpp_11.cmake)
include(@CMAKE_INSTALL_FULL_INCLUDEDIR@/dlib/cmake_utils/use_cpp_11.cmake)
......@@ -10,7 +10,7 @@
#include <string>
#include <sstream>
#include <map>
#include "../smart_pointers.h"
#include <memory>
namespace dlib
{
......@@ -105,7 +105,7 @@ namespace dlib
// Make a separate ostringstream for each option group. We are going to write
// the output for each group to a separate ostringstream so that we can keep
// them grouped together in the final output.
std::map<string,shared_ptr<ostringstream> > groups;
std::map<string,std::shared_ptr<ostringstream> > groups;
this->reset();
while(this->move_next())
{
......@@ -173,7 +173,7 @@ namespace dlib
out << _dT(ct,"Options:");
// Now print everything out
typename std::map<string,shared_ptr<ostringstream> >::iterator i;
typename std::map<string,std::shared_ptr<ostringstream> >::iterator i;
for (i = groups.begin(); i != groups.end(); ++i)
{
// print the group name if we have one
......
......@@ -3,12 +3,13 @@
#ifndef DLIB_DIRECTED_GRAPH_KERNEl_1_
#define DLIB_DIRECTED_GRAPH_KERNEl_1_
#include <memory>
#include <vector>
#include "../serialize.h"
#include "../noncopyable.h"
#include "../std_allocator.h"
#include "../smart_pointers.h"
#include "../algs.h"
#include <vector>
#include "directed_graph_kernel_abstract.h"
#include "../is_kind.h"
......@@ -357,18 +358,18 @@ namespace dlib
private:
friend class directed_graph_kernel_1;
typedef std_allocator<node_type*,mem_manager> alloc_type;
typedef std_allocator<shared_ptr<E>,mem_manager> alloc_edge_type;
typedef std_allocator<std::shared_ptr<E>,mem_manager> alloc_edge_type;
std::vector<node_type*,alloc_type> parents;
std::vector<node_type*,alloc_type> children;
std::vector<shared_ptr<E>,alloc_edge_type> edge_parents;
std::vector<shared_ptr<E>,alloc_edge_type> edge_children;
std::vector<std::shared_ptr<E>,alloc_edge_type> edge_parents;
std::vector<std::shared_ptr<E>,alloc_edge_type> edge_children;
unsigned long idx;
};
private:
typedef std_allocator<shared_ptr<node_type>,mem_manager> alloc_type;
typedef std::vector<shared_ptr<node_type>, alloc_type> vector_type;
typedef std_allocator<std::shared_ptr<node_type>,mem_manager> alloc_type;
typedef std::vector<std::shared_ptr<node_type>, alloc_type> vector_type;
vector_type nodes;
};
......@@ -574,7 +575,7 @@ namespace dlib
p.children.push_back(&c);
c.parents.push_back(&p);
p.edge_children.push_back(shared_ptr<E>(new E));
p.edge_children.push_back(std::shared_ptr<E>(new E));
c.edge_parents.push_back(p.edge_children.back());
}
catch (...)
......@@ -632,7 +633,7 @@ namespace dlib
{
try
{
shared_ptr<node_type> n(new node_type);
std::shared_ptr<node_type> n(new node_type);
n->idx = nodes.size();
nodes.push_back(n);
return n->idx;
......
......@@ -56,6 +56,27 @@ namespace dlib
template <typename T>
double get_weight_decay_multiplier(const T& obj) { return impl::get_weight_decay_multiplier(obj, special_()); }
// ----------------------------------------------------------------------------------------
namespace impl
{
// The reason we return an int for this version rather than doing the more straight forward thing (like we do above) is to avoid a bug in visual studio 2015.
template <typename T>
auto call_clean_method_if_exists (
T& obj,
special_
) -> typename int_<decltype(&T::clean)>::type { obj.clean(); return 0; }
template <typename T>
void call_clean_method_if_exists (T& , general_) {}
}
template <typename T>
void call_clean_method_if_exists(T& obj) { impl::call_clean_method_if_exists(obj, special_()); }
/*!
ensures
- calls obj.clean() if obj has a .clean() method.
!*/
// ----------------------------------------------------------------------------------------
namespace impl
......@@ -893,6 +914,7 @@ namespace dlib
temp_tensor.clear();
gradient_input_is_stale = true;
subnetwork->clean();
call_clean_method_if_exists(details);
}
friend void serialize(const add_layer& item, std::ostream& out)
......@@ -1255,6 +1277,7 @@ namespace dlib
params_grad.clear();
temp_tensor.clear();
gradient_input_is_stale = true;
call_clean_method_if_exists(details);
}
friend void serialize(const add_layer& item, std::ostream& out)
......@@ -3475,6 +3498,71 @@ namespace dlib
impl::vl_loop_backwards<begin,end>::visit(net, v);
}
// ----------------------------------------------------------------------------------------
namespace impl
{
template <size_t i, unsigned long tag_id>
struct vl_until_tag
{
template <
typename net_type,
typename next_net_type,
typename visitor
>
static void visit(
net_type& net,
next_net_type& next_net,
visitor&& v
)
{
v(next_net);
vl_until_tag<i+1,tag_id>::visit(net,layer<i+1>(net),v);
}
template <
typename net_type,
typename SUBNET,
typename visitor
>
static void visit(
net_type& net,
const add_tag_layer<tag_id,SUBNET>& next_net,
visitor&& v
)
{
v(next_net);
}
template <
typename net_type,
typename SUBNET,
typename visitor
>
static void visit(
net_type& net,
add_tag_layer<tag_id,SUBNET>& next_net,
visitor&& v
)
{
v(next_net);
}
};
}
template <
unsigned long tag_id,
typename net_type,
typename visitor
>
void visit_layers_until_tag(
net_type& net,
visitor v
)
{
impl::vl_until_tag<0,tag_id>::visit(net, net, v);
}
// ----------------------------------------------------------------------------------------
}
......
......@@ -562,6 +562,8 @@ namespace dlib
clean(). The purpose of clean() is to compact the network object prior
to saving it to disk so that it takes up less space and the IO is
quicker.
- This also calls the .clean() method on any layer details objects that
define a .clean() method.
!*/
};
......@@ -1578,6 +1580,38 @@ namespace dlib
v(i-1, layer<i-1>(net));
!*/
// ----------------------------------------------------------------------------------------
template <
unsigned long tag_id,
typename net_type,
typename visitor
>
void visit_layers_until_tag(
net_type& net,
visitor v
);
/*!
requires
- net_type is an object of type add_layer, add_loss_layer, add_skip_layer, or
add_tag_layer.
- v is a function object with a signature equivalent to:
v(any_net_type& t)
That is, it must take any of the network types such as add_layer,
add_loss_layer, etc.
ensures
- Loops over all the layers in net beginning with layer<0>(net) and going until
a tag layer with an ID of tag_id is encountered. To be specific, this
function essentially performs the following:
size_t i = 0;
while(layer<i>(net) isn't an add_tag_layer with ID == tag_id) {
v(layer<i>(net));
++i;
}
v(layer<i>(net)); // also visits the tag layer itself at the very end.
!*/
// ----------------------------------------------------------------------------------------
struct layer_test_results
......
......@@ -261,6 +261,57 @@ namespace dlib
}
}
// ----------------------------------------------------------------------------------------
__global__ void _cuda_exp(float* dest, const float* src, size_t n)
{
for (auto i : grid_stride_range(0, n))
dest[i] = ::exp(src[i]);
}
void exp (
tensor& dest,
const tensor& src
)
{
DLIB_ASSERT(dest.size() == src.size());
launch_kernel(_cuda_exp, max_jobs(src.size()), dest.device(), src.device(), src.size());
}
// ----------------------------------------------------------------------------------------
__global__ void _cuda_log(float* dest, const float* src, size_t n)
{
for (auto i : grid_stride_range(0, n))
dest[i] = ::log(src[i]);
}
void log (
tensor& dest,
const tensor& src
)
{
DLIB_ASSERT(dest.size() == src.size());
launch_kernel(_cuda_log, max_jobs(src.size()), dest.device(), src.device(), src.size());
}
// ----------------------------------------------------------------------------------------
__global__ void _cuda_log10(float* dest, const float* src, size_t n)
{
for (auto i : grid_stride_range(0, n))
dest[i] = ::log10(src[i]);
}
void log10 (
tensor& dest,
const tensor& src
)
{
DLIB_ASSERT(dest.size() == src.size());
launch_kernel(_cuda_log10, max_jobs(src.size()), dest.device(), src.device(), src.size());
}
// -----------------------------------------------------------------------------------
__global__ void _cuda_multiply1(float* d, const float* s1, const float* s2, size_t n)
......@@ -1085,7 +1136,8 @@ namespace dlib
grad.device(), src.device(), gradient_input.device(), grad.size(),
param.device(), params_grad.device());
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
void copy_tensor(
tensor& dest,
......@@ -1117,6 +1169,7 @@ namespace dlib
src_p += src_sample_size;
}
}
// ----------------------------------------------------------------------------------------
}
......
......@@ -142,6 +142,21 @@ namespace dlib
const tensor& v2
);
void exp (
tensor& dest,
const tensor& src
);
void log (
tensor& dest,
const tensor& src
);
void log10 (
tensor& dest,
const tensor& src
);
// ------------------------------------------------------------------------------------
void set_tensor (
......
......@@ -91,6 +91,17 @@ namespace dlib
CHECK_CURAND(curandGenerateUniform((curandGenerator_t)handle, data.device(), data.size()));
}
void curand_generator::
fill (
cuda_data_ptr<unsigned int>& data
)
{
if (data.size() == 0)
return;
CHECK_CURAND(curandGenerate((curandGenerator_t)handle, data, data.size()));
}
// -----------------------------------------------------------------------------------
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment