Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
dlib
Commits
3a91295e
Commit
3a91295e
authored
Jun 13, 2017
by
Joachim
Browse files
Merge branch 'master' of
https://github.com/davisking/dlib
parents
22164e5d
75f66582
Changes
122
Hide whitespace changes
Inline
Side-by-side
Showing
20 changed files
with
340 additions
and
121 deletions
+340
-121
appveyor.yml
appveyor.yml
+15
-0
dlib/CMakeLists.txt
dlib/CMakeLists.txt
+41
-36
dlib/any/any.h
dlib/any/any.h
+6
-4
dlib/any/any_decision_function.h
dlib/any/any_decision_function.h
+3
-4
dlib/any/any_function.h
dlib/any/any_function.h
+0
-1
dlib/any/any_function_impl.h
dlib/any/any_function_impl.h
+13
-13
dlib/any/any_trainer.h
dlib/any/any_trainer.h
+3
-4
dlib/bayes_utils/bayes_utils.h
dlib/bayes_utils/bayes_utils.h
+6
-5
dlib/bridge/bridge.h
dlib/bridge/bridge.h
+8
-6
dlib/bsp/bsp.cpp
dlib/bsp/bsp.cpp
+5
-4
dlib/bsp/bsp.h
dlib/bsp/bsp.h
+17
-15
dlib/cmake_utils/dlib.pc.in
dlib/cmake_utils/dlib.pc.in
+2
-4
dlib/cmake_utils/dlibConfig.cmake.in
dlib/cmake_utils/dlibConfig.cmake.in
+6
-12
dlib/cmd_line_parser/cmd_line_parser_print_1.h
dlib/cmd_line_parser/cmd_line_parser_print_1.h
+3
-3
dlib/directed_graph/directed_graph_kernel_1.h
dlib/directed_graph/directed_graph_kernel_1.h
+10
-9
dlib/dnn/core.h
dlib/dnn/core.h
+88
-0
dlib/dnn/core_abstract.h
dlib/dnn/core_abstract.h
+34
-0
dlib/dnn/cuda_dlib.cu
dlib/dnn/cuda_dlib.cu
+54
-1
dlib/dnn/cuda_dlib.h
dlib/dnn/cuda_dlib.h
+15
-0
dlib/dnn/curand_dlibapi.cpp
dlib/dnn/curand_dlibapi.cpp
+11
-0
No files found.
appveyor.yml
0 → 100644
View file @
3a91295e
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
dlib/CMakeLists.txt
View file @
3a91295e
...
@@ -7,6 +7,9 @@
...
@@ -7,6 +7,9 @@
cmake_minimum_required
(
VERSION 2.8.12
)
cmake_minimum_required
(
VERSION 2.8.12
)
project
(
dlib
)
project
(
dlib
)
# Adhere to GNU filesystem layout conventions
include
(
GNUInstallDirs
)
# default to a Release build (except if CMAKE_BUILD_TYPE is set)
# default to a Release build (except if CMAKE_BUILD_TYPE is set)
include
(
cmake_utils/release_build_by_default
)
include
(
cmake_utils/release_build_by_default
)
include
(
cmake_utils/use_cpp_11.cmake
)
include
(
cmake_utils/use_cpp_11.cmake
)
...
@@ -178,6 +181,9 @@ if (NOT TARGET dlib)
...
@@ -178,6 +181,9 @@ if (NOT TARGET dlib)
)
)
set
(
dlib_needed_libraries
)
set
(
dlib_needed_includes
)
if
(
DLIB_ISO_CPP_ONLY
)
if
(
DLIB_ISO_CPP_ONLY
)
add_library
(
dlib STATIC
${
source_files
}
)
add_library
(
dlib STATIC
${
source_files
}
)
if
(
UNIX AND NOT DLIB_IN_PROJECT_BUILD
)
if
(
UNIX AND NOT DLIB_IN_PROJECT_BUILD
)
...
@@ -216,8 +222,6 @@ if (NOT TARGET dlib)
...
@@ -216,8 +222,6 @@ if (NOT TARGET dlib)
stack_trace.cpp
stack_trace.cpp
)
)
set
(
dlib_needed_libraries
)
set
(
dlib_needed_includes
)
if
(
UNIX
)
if
(
UNIX
)
set
(
CMAKE_THREAD_PREFER_PTHREAD ON
)
set
(
CMAKE_THREAD_PREFER_PTHREAD ON
)
find_package
(
Threads REQUIRED
)
find_package
(
Threads REQUIRED
)
...
@@ -596,7 +600,7 @@ if (NOT TARGET dlib)
...
@@ -596,7 +600,7 @@ if (NOT TARGET dlib)
endif
()
endif
()
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
}
set
(
source_files
${
source_files
}
dnn/cuda_dlib.cu
dnn/cuda_dlib.cu
dnn/cudnn_dlibapi.cpp
dnn/cudnn_dlibapi.cpp
...
@@ -670,17 +674,6 @@ if (NOT TARGET dlib)
...
@@ -670,17 +674,6 @@ if (NOT TARGET dlib)
else
()
else
()
add_library
(
dlib STATIC
${
source_files
}
)
add_library
(
dlib STATIC
${
source_files
}
)
endif
()
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
(
UNIX AND NOT DLIB_IN_PROJECT_BUILD
)
if
(
DLIB_USE_CUDA
)
if
(
DLIB_USE_CUDA
)
cuda_add_library
(
dlib_shared SHARED
${
source_files
}
)
cuda_add_library
(
dlib_shared SHARED
${
source_files
}
)
...
@@ -689,17 +682,33 @@ if (NOT TARGET dlib)
...
@@ -689,17 +682,33 @@ if (NOT TARGET dlib)
add_library
(
dlib_shared SHARED
${
source_files
}
)
add_library
(
dlib_shared SHARED
${
source_files
}
)
add_dependencies
(
dlib_shared dlib
)
add_dependencies
(
dlib_shared dlib
)
endif
()
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
()
endif
()
##### end of if NOT DLIB_ISO_CPP_ONLY ##########################################################
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.
# 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
)
if
(
DLIB_TEST_COMPILE_ALL_SOURCE_CPP
)
ADD_LIBRARY
(
dlib_all_source_cpp STATIC all/source.cpp
)
ADD_LIBRARY
(
dlib_all_source_cpp STATIC all/source.cpp
)
...
@@ -709,7 +718,6 @@ if (NOT TARGET dlib)
...
@@ -709,7 +718,6 @@ if (NOT TARGET dlib)
# Install the library
# Install the library
if
(
NOT DLIB_IN_PROJECT_BUILD
)
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
)
cmake_minimum_required
(
VERSION 2.8.8
)
if
(
UNIX
)
if
(
UNIX
)
set_target_properties
(
dlib_shared PROPERTIES
set_target_properties
(
dlib_shared PROPERTIES
...
@@ -717,39 +725,36 @@ if (NOT TARGET dlib)
...
@@ -717,39 +725,36 @@ if (NOT TARGET dlib)
VERSION
${
VERSION
}
)
VERSION
${
VERSION
}
)
install
(
TARGETS dlib dlib_shared
install
(
TARGETS dlib dlib_shared
EXPORT dlib
EXPORT dlib
RUNTIME DESTINATION
bin
# Windows (including cygwin) considers .dll to be runtime artifacts
RUNTIME DESTINATION
${
CMAKE_INSTALL_BINDIR
}
# Windows (including cygwin) considers .dll to be runtime artifacts
LIBRARY DESTINATION
"
${
LIB
_INSTALL_DIR
}
"
LIBRARY DESTINATION
${
CMAKE
_INSTALL_
LIB
DIR
}
ARCHIVE DESTINATION
"
${
LIB
_INSTALL_DIR
}
"
)
ARCHIVE DESTINATION
${
CMAKE
_INSTALL_
LIB
DIR
}
)
else
()
else
()
install
(
TARGETS dlib
install
(
TARGETS dlib
EXPORT dlib
EXPORT dlib
RUNTIME DESTINATION
bin
# Windows considers .dll to be runtime artifacts
RUNTIME DESTINATION
${
CMAKE_INSTALL_BINDIR
}
# Windows considers .dll to be runtime artifacts
LIBRARY DESTINATION
lib
LIBRARY DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
ARCHIVE DESTINATION
lib
)
ARCHIVE DESTINATION
${
CMAKE_INSTALL_LIBDIR
}
)
endif
()
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"
FILES_MATCHING PATTERN
"*.h"
PATTERN
"*.cmake"
REGEX
"
${
CMAKE_CURRENT_BINARY_DIR
}
"
EXCLUDE
)
REGEX
"
${
CMAKE_CURRENT_BINARY_DIR
}
"
EXCLUDE
)
configure_file
(
${
PROJECT_SOURCE_DIR
}
/config.h.in
${
CMAKE_CURRENT_BINARY_DIR
}
/config.h
)
configure_file
(
${
PROJECT_SOURCE_DIR
}
/config.h.in
${
CMAKE_CURRENT_BINARY_DIR
}
/config.h
)
# overwrite config.h with the configured one
# 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
)
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
${
CMAKE_CURRENT_BINARY_DIR
}
/revision.h DESTINATION
${
CMAKE_INSTALL_INCLUDEDIR
}
/dlib
)
install
(
FILES
"LICENSE.txt"
DESTINATION share/doc/dlib
)
## Config.cmake generation and installation
## Config.cmake generation and installation
set
(
ConfigPackageLocation
"
${
LIB
_INSTALL_DIR
}
/cmake/dlib"
)
set
(
ConfigPackageLocation
"
${
CMAKE
_INSTALL_
LIB
DIR
}
/cmake/dlib"
)
install
(
EXPORT dlib
install
(
EXPORT dlib
NAMESPACE dlib::
NAMESPACE dlib::
DESTINATION
${
ConfigPackageLocation
}
)
DESTINATION
${
ConfigPackageLocation
}
)
set
(
CONF_INSTALL_PATH
"
\$
{dlib_CMAKE_DIR}/../../../"
)
configure_file
(
cmake_utils/dlibConfig.cmake.in
"
${
CMAKE_CURRENT_BINARY_DIR
}
/config/dlibConfig.cmake"
@ONLY
)
configure_file
(
cmake_utils/dlibConfig.cmake.in
"
${
CMAKE_CURRENT_BINARY_DIR
}
/config/dlibConfig.cmake"
@ONLY
)
include
(
CMakePackageConfigHelpers
)
include
(
CMakePackageConfigHelpers
)
...
@@ -768,7 +773,7 @@ if (NOT TARGET dlib)
...
@@ -768,7 +773,7 @@ if (NOT TARGET dlib)
configure_file
(
"cmake_utils/dlib.pc.in"
"dlib-1.pc"
@ONLY
)
configure_file
(
"cmake_utils/dlib.pc.in"
"dlib-1.pc"
@ONLY
)
install
(
FILES
"
${
CMAKE_CURRENT_BINARY_DIR
}
/dlib-1.pc"
install
(
FILES
"
${
CMAKE_CURRENT_BINARY_DIR
}
/dlib-1.pc"
DESTINATION
"
${
LIB
_INSTALL_DIR
}
/pkgconfig"
)
DESTINATION
"
${
CMAKE
_INSTALL_
LIB
DIR
}
/pkgconfig"
)
endif
()
endif
()
...
...
dlib/any/any.h
View file @
3a91295e
...
@@ -4,7 +4,9 @@
...
@@ -4,7 +4,9 @@
#define DLIB_AnY_H_
#define DLIB_AnY_H_
#include "any_abstract.h"
#include "any_abstract.h"
#include "../smart_pointers.h"
#include "../algs.h"
#include <memory>
#include <typeinfo>
#include <typeinfo>
namespace
dlib
namespace
dlib
...
@@ -136,7 +138,7 @@ namespace dlib
...
@@ -136,7 +138,7 @@ namespace dlib
virtual
~
base
()
{}
virtual
~
base
()
{}
virtual
void
copy_to
(
virtual
void
copy_to
(
s
coped
_ptr
<
base
>&
dest
s
td
::
unique
_ptr
<
base
>&
dest
)
const
=
0
;
)
const
=
0
;
};
};
...
@@ -148,14 +150,14 @@ namespace dlib
...
@@ -148,14 +150,14 @@ namespace dlib
derived
(
const
T
&
val
)
:
item
(
val
)
{}
derived
(
const
T
&
val
)
:
item
(
val
)
{}
virtual
void
copy_to
(
virtual
void
copy_to
(
s
coped
_ptr
<
base
>&
dest
s
td
::
unique
_ptr
<
base
>&
dest
)
const
)
const
{
{
dest
.
reset
(
new
derived
<
T
>
(
item
));
dest
.
reset
(
new
derived
<
T
>
(
item
));
}
}
};
};
s
coped
_ptr
<
base
>
data
;
s
td
::
unique
_ptr
<
base
>
data
;
};
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
dlib/any/any_decision_function.h
View file @
3a91295e
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
#define DLIB_AnY_DECISION_FUNCTION_Hh_
#define DLIB_AnY_DECISION_FUNCTION_Hh_
#include "any.h"
#include "any.h"
#include "../smart_pointers.h"
#include "any_decision_function_abstract.h"
#include "any_decision_function_abstract.h"
...
@@ -148,7 +147,7 @@ namespace dlib
...
@@ -148,7 +147,7 @@ namespace dlib
virtual
~
base
()
{}
virtual
~
base
()
{}
virtual
void
copy_to
(
virtual
void
copy_to
(
s
coped
_ptr
<
base
>&
dest
s
td
::
unique
_ptr
<
base
>&
dest
)
const
=
0
;
)
const
=
0
;
virtual
result_type
evaluate
(
virtual
result_type
evaluate
(
...
@@ -164,7 +163,7 @@ namespace dlib
...
@@ -164,7 +163,7 @@ namespace dlib
derived
(
const
T
&
val
)
:
item
(
val
)
{}
derived
(
const
T
&
val
)
:
item
(
val
)
{}
virtual
void
copy_to
(
virtual
void
copy_to
(
s
coped
_ptr
<
base
>&
dest
s
td
::
unique
_ptr
<
base
>&
dest
)
const
)
const
{
{
dest
.
reset
(
new
derived
<
T
>
(
item
));
dest
.
reset
(
new
derived
<
T
>
(
item
));
...
@@ -178,7 +177,7 @@ namespace dlib
...
@@ -178,7 +177,7 @@ namespace dlib
}
}
};
};
s
coped
_ptr
<
base
>
data
;
s
td
::
unique
_ptr
<
base
>
data
;
};
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
dlib/any/any_function.h
View file @
3a91295e
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
#define DLIB_AnY_FUNCTION_Hh_
#define DLIB_AnY_FUNCTION_Hh_
#include "any.h"
#include "any.h"
#include "../smart_pointers.h"
#include "any_function_abstract.h"
#include "any_function_abstract.h"
...
...
dlib/any/any_function_impl.h
View file @
3a91295e
...
@@ -166,7 +166,7 @@ struct Tbase
...
@@ -166,7 +166,7 @@ struct Tbase
{
{
virtual
~
Tbase
()
{}
virtual
~
Tbase
()
{}
virtual
result_type
evaluate
()
const
=
0
;
virtual
result_type
evaluate
()
const
=
0
;
virtual
void
copy_to
(
s
coped
_ptr
<
Tbase
>&
dest
)
const
=
0
;
virtual
void
copy_to
(
s
td
::
unique
_ptr
<
Tbase
>&
dest
)
const
=
0
;
};
};
template
<
template
<
...
@@ -177,7 +177,7 @@ struct Tbase<T (A1)>
...
@@ -177,7 +177,7 @@ struct Tbase<T (A1)>
{
{
virtual
~
Tbase
()
{}
virtual
~
Tbase
()
{}
virtual
T
evaluate
(
A1
)
const
=
0
;
virtual
T
evaluate
(
A1
)
const
=
0
;
virtual
void
copy_to
(
s
coped
_ptr
<
Tbase
>&
dest
)
const
=
0
;
virtual
void
copy_to
(
s
td
::
unique
_ptr
<
Tbase
>&
dest
)
const
=
0
;
};
};
template
<
template
<
...
@@ -188,7 +188,7 @@ struct Tbase<T (A1,A2)>
...
@@ -188,7 +188,7 @@ struct Tbase<T (A1,A2)>
{
{
virtual
~
Tbase
()
{}
virtual
~
Tbase
()
{}
virtual
T
evaluate
(
A1
,
A2
)
const
=
0
;
virtual
T
evaluate
(
A1
,
A2
)
const
=
0
;
virtual
void
copy_to
(
s
coped
_ptr
<
Tbase
>&
dest
)
const
=
0
;
virtual
void
copy_to
(
s
td
::
unique
_ptr
<
Tbase
>&
dest
)
const
=
0
;
};
};
template
<
template
<
...
@@ -199,7 +199,7 @@ struct Tbase<T (A1,A2,A3)>
...
@@ -199,7 +199,7 @@ struct Tbase<T (A1,A2,A3)>
{
{
virtual
~
Tbase
()
{}
virtual
~
Tbase
()
{}
virtual
T
evaluate
(
A1
,
A2
,
A3
)
const
=
0
;
virtual
T
evaluate
(
A1
,
A2
,
A3
)
const
=
0
;
virtual
void
copy_to
(
s
coped
_ptr
<
Tbase
>&
dest
)
const
=
0
;
virtual
void
copy_to
(
s
td
::
unique
_ptr
<
Tbase
>&
dest
)
const
=
0
;
};
};
template
<
template
<
...
@@ -211,7 +211,7 @@ struct Tbase<T (A1,A2,A3,A4)>
...
@@ -211,7 +211,7 @@ struct Tbase<T (A1,A2,A3,A4)>
{
{
virtual
~
Tbase
()
{}
virtual
~
Tbase
()
{}
virtual
T
evaluate
(
A1
,
A2
,
A3
,
A4
)
const
=
0
;
virtual
T
evaluate
(
A1
,
A2
,
A3
,
A4
)
const
=
0
;
virtual
void
copy_to
(
s
coped
_ptr
<
Tbase
>&
dest
)
const
=
0
;
virtual
void
copy_to
(
s
td
::
unique
_ptr
<
Tbase
>&
dest
)
const
=
0
;
};
};
template
<
template
<
...
@@ -223,7 +223,7 @@ struct Tbase<T (A1,A2,A3,A4,A5)>
...
@@ -223,7 +223,7 @@ struct Tbase<T (A1,A2,A3,A4,A5)>
{
{
virtual
~
Tbase
()
{}
virtual
~
Tbase
()
{}
virtual
T
evaluate
(
A1
,
A2
,
A3
,
A4
,
A5
)
const
=
0
;
virtual
T
evaluate
(
A1
,
A2
,
A3
,
A4
,
A5
)
const
=
0
;
virtual
void
copy_to
(
s
coped
_ptr
<
Tbase
>&
dest
)
const
=
0
;
virtual
void
copy_to
(
s
td
::
unique
_ptr
<
Tbase
>&
dest
)
const
=
0
;
};
};
template
<
template
<
...
@@ -235,7 +235,7 @@ struct Tbase<T (A1,A2,A3,A4,A5,A6)>
...
@@ -235,7 +235,7 @@ struct Tbase<T (A1,A2,A3,A4,A5,A6)>
{
{
virtual
~
Tbase
()
{}
virtual
~
Tbase
()
{}
virtual
T
evaluate
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
)
const
=
0
;
virtual
T
evaluate
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
)
const
=
0
;
virtual
void
copy_to
(
s
coped
_ptr
<
Tbase
>&
dest
)
const
=
0
;
virtual
void
copy_to
(
s
td
::
unique
_ptr
<
Tbase
>&
dest
)
const
=
0
;
};
};
template
<
template
<
...
@@ -248,7 +248,7 @@ struct Tbase<T (A1,A2,A3,A4,A5,A6,A7)>
...
@@ -248,7 +248,7 @@ struct Tbase<T (A1,A2,A3,A4,A5,A6,A7)>
{
{
virtual
~
Tbase
()
{}
virtual
~
Tbase
()
{}
virtual
T
evaluate
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
)
const
=
0
;
virtual
T
evaluate
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
)
const
=
0
;
virtual
void
copy_to
(
s
coped
_ptr
<
Tbase
>&
dest
)
const
=
0
;
virtual
void
copy_to
(
s
td
::
unique
_ptr
<
Tbase
>&
dest
)
const
=
0
;
};
};
template
<
template
<
...
@@ -261,7 +261,7 @@ struct Tbase<T (A1,A2,A3,A4,A5,A6,A7,A8)>
...
@@ -261,7 +261,7 @@ struct Tbase<T (A1,A2,A3,A4,A5,A6,A7,A8)>
{
{
virtual
~
Tbase
()
{}
virtual
~
Tbase
()
{}
virtual
T
evaluate
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
)
const
=
0
;
virtual
T
evaluate
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
)
const
=
0
;
virtual
void
copy_to
(
s
coped
_ptr
<
Tbase
>&
dest
)
const
=
0
;
virtual
void
copy_to
(
s
td
::
unique
_ptr
<
Tbase
>&
dest
)
const
=
0
;
};
};
template
<
template
<
...
@@ -274,7 +274,7 @@ struct Tbase<T (A1,A2,A3,A4,A5,A6,A7,A8,A9)>
...
@@ -274,7 +274,7 @@ struct Tbase<T (A1,A2,A3,A4,A5,A6,A7,A8,A9)>
{
{
virtual
~
Tbase
()
{}
virtual
~
Tbase
()
{}
virtual
T
evaluate
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
)
const
=
0
;
virtual
T
evaluate
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
)
const
=
0
;
virtual
void
copy_to
(
s
coped
_ptr
<
Tbase
>&
dest
)
const
=
0
;
virtual
void
copy_to
(
s
td
::
unique
_ptr
<
Tbase
>&
dest
)
const
=
0
;
};
};
template
<
template
<
...
@@ -288,7 +288,7 @@ struct Tbase<T (A1,A2,A3,A4,A5,A6,A7,A8,A9,A10)>
...
@@ -288,7 +288,7 @@ struct Tbase<T (A1,A2,A3,A4,A5,A6,A7,A8,A9,A10)>
{
{
virtual
~
Tbase
()
{}
virtual
~
Tbase
()
{}
virtual
T
evaluate
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
,
A10
)
const
=
0
;
virtual
T
evaluate
(
A1
,
A2
,
A3
,
A4
,
A5
,
A6
,
A7
,
A8
,
A9
,
A10
)
const
=
0
;
virtual
void
copy_to
(
s
coped
_ptr
<
Tbase
>&
dest
)
const
=
0
;
virtual
void
copy_to
(
s
td
::
unique
_ptr
<
Tbase
>&
dest
)
const
=
0
;
};
};
typedef
Tbase
<
function_type
>
base
;
typedef
Tbase
<
function_type
>
base
;
...
@@ -318,7 +318,7 @@ static typename disable_if<is_function<T>,const T&>::type deref (const U& item)
...
@@ -318,7 +318,7 @@ static typename disable_if<is_function<T>,const T&>::type deref (const U& item)
typename funct_type<T>::type item; \
typename funct_type<T>::type item; \
derived() {} \
derived() {} \
derived(const T& val) : item(copy(val)) {} \
derived(const T& val) : item(copy(val)) {} \
virtual void copy_to ( s
coped
_ptr<base>& dest) const \
virtual void copy_to ( s
td::unique
_ptr<base>& dest) const \
{ dest.reset(new derived(deref<T>(item))); }
{ dest.reset(new derived(deref<T>(item))); }
template
<
typename
T
,
typename
FT
>
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
...
@@ -508,7 +508,7 @@ struct derived<T,result_type (A1,A2,A3,A4,A5,A6,A7,A8,A9,A10)> : public base
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
};
};
s
coped
_ptr
<
base
>
data
;
s
td
::
unique
_ptr
<
base
>
data
;
#undef DLIB_ANY_FUNCTION_DERIVED_BOILERPLATE
#undef DLIB_ANY_FUNCTION_DERIVED_BOILERPLATE
...
...
dlib/any/any_trainer.h
View file @
3a91295e
...
@@ -4,7 +4,6 @@
...
@@ -4,7 +4,6 @@
#define DLIB_AnY_TRAINER_H_
#define DLIB_AnY_TRAINER_H_
#include "any.h"
#include "any.h"
#include "../smart_pointers.h"
#include "any_decision_function.h"
#include "any_decision_function.h"
...
@@ -157,7 +156,7 @@ namespace dlib
...
@@ -157,7 +156,7 @@ namespace dlib
)
const
=
0
;
)
const
=
0
;
virtual
void
copy_to
(
virtual
void
copy_to
(
s
coped
_ptr
<
base
>&
dest
s
td
::
unique
_ptr
<
base
>&
dest
)
const
=
0
;
)
const
=
0
;
};
};
...
@@ -169,7 +168,7 @@ namespace dlib
...
@@ -169,7 +168,7 @@ namespace dlib
derived
(
const
T
&
val
)
:
item
(
val
)
{}
derived
(
const
T
&
val
)
:
item
(
val
)
{}
virtual
void
copy_to
(
virtual
void
copy_to
(
s
coped
_ptr
<
base
>&
dest
s
td
::
unique
_ptr
<
base
>&
dest
)
const
)
const
{
{
dest
.
reset
(
new
derived
<
T
>
(
item
));
dest
.
reset
(
new
derived
<
T
>
(
item
));
...
@@ -184,7 +183,7 @@ namespace dlib
...
@@ -184,7 +183,7 @@ namespace dlib
}
}
};
};
s
coped
_ptr
<
base
>
data
;
s
td
::
unique
_ptr
<
base
>
data
;
};
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
dlib/bayes_utils/bayes_utils.h
View file @
3a91295e
...
@@ -5,6 +5,11 @@
...
@@ -5,6 +5,11 @@
#include "bayes_utils_abstract.h"
#include "bayes_utils_abstract.h"
#include <algorithm>
#include <ctime>
#include <memory>
#include <vector>
#include "../string.h"
#include "../string.h"
#include "../map.h"
#include "../map.h"
#include "../matrix.h"
#include "../matrix.h"
...
@@ -13,11 +18,7 @@
...
@@ -13,11 +18,7 @@
#include "../set.h"
#include "../set.h"
#include "../algs.h"
#include "../algs.h"
#include "../noncopyable.h"
#include "../noncopyable.h"
#include "../smart_pointers.h"
#include "../graph.h"
#include "../graph.h"
#include <vector>
#include <algorithm>
#include <ctime>
namespace
dlib
namespace
dlib
{
{
...
@@ -1659,7 +1660,7 @@ namespace dlib
...
@@ -1659,7 +1660,7 @@ namespace dlib
private:
private:
s
coped
_ptr
<
bayesian_network_join_tree_helpers
::
bnjt
>
impl
;
s
td
::
unique
_ptr
<
bayesian_network_join_tree_helpers
::
bnjt
>
impl
;
unsigned
long
num_nodes
;
unsigned
long
num_nodes
;
};
};
...
...
dlib/bridge/bridge.h
View file @
3a91295e
...
@@ -3,17 +3,19 @@
...
@@ -3,17 +3,19 @@
#ifndef DLIB_BRIDGe_Hh_
#ifndef DLIB_BRIDGe_Hh_
#define DLIB_BRIDGe_Hh_
#define DLIB_BRIDGe_Hh_
#include "bridge_abstract.h"
#include <iostream>
#include <memory>
#include <string>
#include <string>
#include "bridge_abstract.h"
#include "../pipe.h"
#include "../pipe.h"
#include "../threads.h"
#include "../threads.h"
#include "../smart_pointers.h"
#include "../serialize.h"
#include "../serialize.h"
#include "../sockets.h"
#include "../sockets.h"
#include "../sockstreambuf.h"
#include "../sockstreambuf.h"
#include "../logger.h"
#include "../logger.h"
#include "../algs.h"
#include "../algs.h"
#include <iostream>
namespace
dlib
namespace
dlib
{
{
...
@@ -545,8 +547,8 @@ namespace dlib
...
@@ -545,8 +547,8 @@ namespace dlib
signaler
s
;
signaler
s
;
bool
receive_thread_active
;
bool
receive_thread_active
;
bool
transmit_thread_active
;
bool
transmit_thread_active
;
s
coped
_ptr
<
connection
>
con
;
s
td
::
unique
_ptr
<
connection
>
con
;
s
coped
_ptr
<
listener
>
list
;
s
td
::
unique
_ptr
<
listener
>
list
;
const
unsigned
short
port
;
const
unsigned
short
port
;
const
std
::
string
ip
;
const
std
::
string
ip
;
transmit_pipe_type
*
const
transmit_pipe
;
transmit_pipe_type
*
const
transmit_pipe
;
...
@@ -656,7 +658,7 @@ namespace dlib
...
@@ -656,7 +658,7 @@ namespace dlib
private:
private:
s
coped
_ptr
<
impl_brns
::
impl_bridge_base
>
pimpl
;
s
td
::
unique
_ptr
<
impl_brns
::
impl_bridge_base
>
pimpl
;
};
};
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
...
dlib/bsp/bsp.cpp
View file @
3a91295e
...
@@ -4,6 +4,7 @@
...
@@ -4,6 +4,7 @@
#define DLIB_BSP_CPph_
#define DLIB_BSP_CPph_
#include "bsp.h"
#include "bsp.h"
#include <memory>
#include <stack>
#include <stack>
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
...
@@ -24,7 +25,7 @@ namespace dlib
...
@@ -24,7 +25,7 @@ namespace dlib
cons
.
clear
();
cons
.
clear
();
for
(
unsigned
long
i
=
0
;
i
<
hosts
.
size
();
++
i
)
for
(
unsigned
long
i
=
0
;
i
<
hosts
.
size
();
++
i
)
{
{
s
coped
_ptr
<
bsp_con
>
con
(
new
bsp_con
(
hosts
[
i
]));
s
td
::
unique
_ptr
<
bsp_con
>
con
(
new
bsp_con
(
hosts
[
i
]));
dlib
::
serialize
(
node_id
,
con
->
stream
);
// tell the other end our node_id
dlib
::
serialize
(
node_id
,
con
->
stream
);
// tell the other end our node_id
unsigned
long
id
=
i
+
1
;
unsigned
long
id
=
i
+
1
;
cons
.
add
(
id
,
con
);
cons
.
add
(
id
,
con
);
...
@@ -43,7 +44,7 @@ namespace dlib
...
@@ -43,7 +44,7 @@ namespace dlib
{
{
try
try
{
{
s
coped
_ptr
<
bsp_con
>
con
(
new
bsp_con
(
hosts
[
i
].
addr
));
s
td
::
unique
_ptr
<
bsp_con
>
con
(
new
bsp_con
(
hosts
[
i
].
addr
));
dlib
::
serialize
(
node_id
,
con
->
stream
);
// tell the other end our node_id
dlib
::
serialize
(
node_id
,
con
->
stream
);
// tell the other end our node_id
con
->
stream
.
flush
();
con
->
stream
.
flush
();
unsigned
long
id
=
hosts
[
i
].
node_id
;
unsigned
long
id
=
hosts
[
i
].
node_id
;
...
@@ -316,7 +317,7 @@ namespace dlib
...
@@ -316,7 +317,7 @@ namespace dlib
_cons
.
reset
();
_cons
.
reset
();
while
(
_cons
.
move_next
())
while
(
_cons
.
move_next
())
{
{
s
coped
_ptr
<
thread_function
>
ptr
(
new
thread_function
(
&
impl2
::
read_thread
,
s
td
::
unique
_ptr
<
thread_function
>
ptr
(
new
thread_function
(
&
impl2
::
read_thread
,
_cons
.
element
().
value
().
get
(),
_cons
.
element
().
value
().
get
(),
_node_id
,
_node_id
,
_cons
.
element
().
key
(),
_cons
.
element
().
key
(),
...
@@ -330,7 +331,7 @@ namespace dlib
...
@@ -330,7 +331,7 @@ namespace dlib
bool
bsp_context
::
bool
bsp_context
::
receive_data
(
receive_data
(
shared_ptr
<
std
::
vector
<
char
>
>&
item
,
std
::
shared_ptr
<
std
::
vector
<
char
>
>&
item
,
unsigned
long
&
sending_node_id
unsigned
long
&
sending_node_id
)
)
{
{
...
...
dlib/bsp/bsp.h
View file @
3a91295e
...
@@ -4,17 +4,19 @@
...
@@ -4,17 +4,19 @@
#define DLIB_BsP_Hh_
#define DLIB_BsP_Hh_
#include "bsp_abstract.h"
#include "bsp_abstract.h"
#include <memory>
#include <queue>
#include <vector>
#include "../sockets.h"
#include "../sockets.h"
#include "../array.h"
#include "../array.h"
#include "../smart_pointers.h"
#include "../sockstreambuf.h"
#include "../sockstreambuf.h"
#include "../string.h"
#include "../string.h"
#include "../serialize.h"
#include "../serialize.h"
#include "../map.h"
#include "../map.h"
#include "../ref.h"
#include "../ref.h"
#include "../vectorstream.h"
#include "../vectorstream.h"
#include <queue>
#include <vector>
namespace
dlib
namespace
dlib
{
{
...
@@ -41,7 +43,7 @@ namespace dlib
...
@@ -41,7 +43,7 @@ namespace dlib
}
}
bsp_con
(
bsp_con
(
s
coped
_ptr
<
connection
>&
conptr
s
td
::
unique
_ptr
<
connection
>&
conptr
)
:
)
:
buf
(
conptr
),
buf
(
conptr
),
stream
(
&
buf
),
stream
(
&
buf
),
...
@@ -53,13 +55,13 @@ namespace dlib
...
@@ -53,13 +55,13 @@ namespace dlib
con
->
disable_nagle
();
con
->
disable_nagle
();
}
}
s
coped
_ptr
<
connection
>
con
;
s
td
::
unique
_ptr
<
connection
>
con
;
sockstreambuf
buf
;
sockstreambuf
buf
;
std
::
iostream
stream
;
std
::
iostream
stream
;
bool
terminated
;
bool
terminated
;
};
};
typedef
dlib
::
map
<
unsigned
long
,
s
coped
_ptr
<
bsp_con
>
>::
kernel_1a_c
map_id_to_con
;
typedef
dlib
::
map
<
unsigned
long
,
s
td
::
unique
_ptr
<
bsp_con
>
>::
kernel_1a_c
map_id_to_con
;
void
connect_all
(
void
connect_all
(
map_id_to_con
&
cons
,
map_id_to_con
&
cons
,
...
@@ -134,7 +136,7 @@ namespace dlib
...
@@ -134,7 +136,7 @@ namespace dlib
)
)
{
{
cons
.
clear
();
cons
.
clear
();
s
coped
_ptr
<
listener
>
list
;
s
td
::
unique
_ptr
<
listener
>
list
;
const
int
status
=
create_listener
(
list
,
port
);
const
int
status
=
create_listener
(
list
,
port
);
if
(
status
==
PORTINUSE
)
if
(
status
==
PORTINUSE
)
{
{
...
@@ -148,13 +150,13 @@ namespace dlib
...
@@ -148,13 +150,13 @@ namespace dlib
port_notify_function
(
list
->
get_listening_port
());
port_notify_function
(
list
->
get_listening_port
());
s
coped
_ptr
<
connection
>
con
;
s
td
::
unique
_ptr
<
connection
>
con
;
if
(
list
->
accept
(
con
))
if
(
list
->
accept
(
con
))
{
{
throw
socket_error
(
"Error occurred while accepting new connection"
);
throw
socket_error
(
"Error occurred while accepting new connection"
);
}
}
s
coped
_ptr
<
bsp_con
>
temp
(
new
bsp_con
(
con
));
s
td
::
unique
_ptr
<
bsp_con
>
temp
(
new
bsp_con
(
con
));
unsigned
long
remote_node_id
;
unsigned
long
remote_node_id
;
dlib
::
deserialize
(
remote_node_id
,
temp
->
stream
);
dlib
::
deserialize
(
remote_node_id
,
temp
->
stream
);
...
@@ -197,7 +199,7 @@ namespace dlib
...
@@ -197,7 +199,7 @@ namespace dlib
while
(
cons2
.
size
()
>
0
)
while
(
cons2
.
size
()
>
0
)
{
{
unsigned
long
id
;
unsigned
long
id
;
s
coped
_ptr
<
bsp_con
>
temp
;
s
td
::
unique
_ptr
<
bsp_con
>
temp
;
cons2
.
remove_any
(
id
,
temp
);
cons2
.
remove_any
(
id
,
temp
);
cons
.
add
(
id
,
temp
);
cons
.
add
(
id
,
temp
);
}
}
...
@@ -207,7 +209,7 @@ namespace dlib
...
@@ -207,7 +209,7 @@ namespace dlib
struct
msg_data
struct
msg_data
{
{
shared_ptr
<
std
::
vector
<
char
>
>
data
;
std
::
shared_ptr
<
std
::
vector
<
char
>
>
data
;
unsigned
long
sender_id
;
unsigned
long
sender_id
;
char
msg_type
;
char
msg_type
;
dlib
::
uint64
epoch
;
dlib
::
uint64
epoch
;
...
@@ -420,7 +422,7 @@ namespace dlib
...
@@ -420,7 +422,7 @@ namespace dlib
)
)
{
{
unsigned
long
id
;
unsigned
long
id
;
shared_ptr
<
std
::
vector
<
char
>
>
temp
;
std
::
shared_ptr
<
std
::
vector
<
char
>
>
temp
;
if
(
receive_data
(
temp
,
id
))
if
(
receive_data
(
temp
,
id
))
throw
dlib
::
socket_error
(
"Call to bsp_context::receive() got an unexpected message."
);
throw
dlib
::
socket_error
(
"Call to bsp_context::receive() got an unexpected message."
);
}
}
...
@@ -459,7 +461,7 @@ namespace dlib
...
@@ -459,7 +461,7 @@ namespace dlib
unsigned
long
&
sending_node_id
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
))
if
(
receive_data
(
temp
,
sending_node_id
))
{
{
vectorstream
sin
(
*
temp
);
vectorstream
sin
(
*
temp
);
...
@@ -496,7 +498,7 @@ namespace dlib
...
@@ -496,7 +498,7 @@ namespace dlib
!*/
!*/
bool
receive_data
(
bool
receive_data
(
shared_ptr
<
std
::
vector
<
char
>
>&
item
,
std
::
shared_ptr
<
std
::
vector
<
char
>
>&
item
,
unsigned
long
&
sending_node_id
unsigned
long
&
sending_node_id
);
);
...
@@ -533,7 +535,7 @@ namespace dlib
...
@@ -533,7 +535,7 @@ namespace dlib
impl1
::
map_id_to_con
&
_cons
;
impl1
::
map_id_to_con
&
_cons
;
const
unsigned
long
_node_id
;
const
unsigned
long
_node_id
;
array
<
s
coped
_ptr
<
thread_function
>
>
threads
;
array
<
s
td
::
unique
_ptr
<
thread_function
>
>
threads
;
// -----------------------------------
// -----------------------------------
...
...
dlib/cmake_utils/dlib.pc.in
View file @
3a91295e
prefix=@CMAKE_INSTALL_PREFIX@
libdir=@CMAKE_INSTALL_FULL_LIBDIR@
exec_prefix=${prefix}
includedir=@CMAKE_INSTALL_FULL_INCLUDEDIR@
libdir=${exec_prefix}/@LIB_INSTALL_DIR@
includedir=${prefix}/include
Name: @PROJECT_NAME@
Name: @PROJECT_NAME@
Description: Numerical and networking C++ library
Description: Numerical and networking C++ library
...
...
dlib/cmake_utils/dlibConfig.cmake.in
View file @
3a91295e
...
@@ -19,24 +19,18 @@
...
@@ -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)
# Our library dependencies (contains definitions for IMPORTED targets)
if(NOT TARGET dlib-shared AND NOT dlib_BINARY_DIR)
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()
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_LIBRARIES ${dlib_LIBRARIES} "@dlib_needed_libraries@")
set(dlib_LIBS ${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)
dlib/cmd_line_parser/cmd_line_parser_print_1.h
View file @
3a91295e
...
@@ -10,7 +10,7 @@
...
@@ -10,7 +10,7 @@
#include <string>
#include <string>
#include <sstream>
#include <sstream>
#include <map>
#include <map>
#include
"../smart_pointers.h"
#include
<memory>
namespace
dlib
namespace
dlib
{
{
...
@@ -105,7 +105,7 @@ namespace dlib
...
@@ -105,7 +105,7 @@ namespace dlib
// Make a separate ostringstream for each option group. We are going to write
// 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
// the output for each group to a separate ostringstream so that we can keep
// them grouped together in the final output.
// them grouped together in the final output.
std
::
map
<
string
,
shared_ptr
<
ostringstream
>
>
groups
;
std
::
map
<
string
,
std
::
shared_ptr
<
ostringstream
>
>
groups
;
this
->
reset
();
this
->
reset
();
while
(
this
->
move_next
())
while
(
this
->
move_next
())
{
{
...
@@ -173,7 +173,7 @@ namespace dlib
...
@@ -173,7 +173,7 @@ namespace dlib
out
<<
_dT
(
ct
,
"Options:"
);
out
<<
_dT
(
ct
,
"Options:"
);
// Now print everything out
// 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
)
for
(
i
=
groups
.
begin
();
i
!=
groups
.
end
();
++
i
)
{
{
// print the group name if we have one
// print the group name if we have one
...
...
dlib/directed_graph/directed_graph_kernel_1.h
View file @
3a91295e
...
@@ -3,12 +3,13 @@
...
@@ -3,12 +3,13 @@
#ifndef DLIB_DIRECTED_GRAPH_KERNEl_1_
#ifndef DLIB_DIRECTED_GRAPH_KERNEl_1_
#define DLIB_DIRECTED_GRAPH_KERNEl_1_
#define DLIB_DIRECTED_GRAPH_KERNEl_1_
#include <memory>
#include <vector>
#include "../serialize.h"
#include "../serialize.h"
#include "../noncopyable.h"
#include "../noncopyable.h"
#include "../std_allocator.h"
#include "../std_allocator.h"
#include "../smart_pointers.h"
#include "../algs.h"
#include "../algs.h"
#include <vector>
#include "directed_graph_kernel_abstract.h"
#include "directed_graph_kernel_abstract.h"
#include "../is_kind.h"
#include "../is_kind.h"
...
@@ -357,18 +358,18 @@ namespace dlib
...
@@ -357,18 +358,18 @@ namespace dlib
private:
private:
friend
class
directed_graph_kernel_1
;
friend
class
directed_graph_kernel_1
;
typedef
std_allocator
<
node_type
*
,
mem_manager
>
alloc_type
;
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
>
parents
;
std
::
vector
<
node_type
*
,
alloc_type
>
children
;
std
::
vector
<
node_type
*
,
alloc_type
>
children
;
std
::
vector
<
shared_ptr
<
E
>
,
alloc_edge_type
>
edge_parents
;
std
::
vector
<
std
::
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_children
;
unsigned
long
idx
;
unsigned
long
idx
;
};
};
private:
private:
typedef
std_allocator
<
shared_ptr
<
node_type
>
,
mem_manager
>
alloc_type
;
typedef
std_allocator
<
std
::
shared_ptr
<
node_type
>
,
mem_manager
>
alloc_type
;
typedef
std
::
vector
<
shared_ptr
<
node_type
>
,
alloc_type
>
vector_type
;
typedef
std
::
vector
<
std
::
shared_ptr
<
node_type
>
,
alloc_type
>
vector_type
;
vector_type
nodes
;
vector_type
nodes
;
};
};
...
@@ -574,7 +575,7 @@ namespace dlib
...
@@ -574,7 +575,7 @@ namespace dlib
p
.
children
.
push_back
(
&
c
);
p
.
children
.
push_back
(
&
c
);
c
.
parents
.
push_back
(
&
p
);
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
());
c
.
edge_parents
.
push_back
(
p
.
edge_children
.
back
());
}
}
catch
(...)
catch
(...)
...
@@ -632,7 +633,7 @@ namespace dlib
...
@@ -632,7 +633,7 @@ namespace dlib
{
{
try
try
{
{
shared_ptr
<
node_type
>
n
(
new
node_type
);
std
::
shared_ptr
<
node_type
>
n
(
new
node_type
);
n
->
idx
=
nodes
.
size
();
n
->
idx
=
nodes
.
size
();
nodes
.
push_back
(
n
);
nodes
.
push_back
(
n
);
return
n
->
idx
;
return
n
->
idx
;
...
...
dlib/dnn/core.h
View file @
3a91295e
...
@@ -56,6 +56,27 @@ namespace dlib
...
@@ -56,6 +56,27 @@ namespace dlib
template
<
typename
T
>
template
<
typename
T
>
double
get_weight_decay_multiplier
(
const
T
&
obj
)
{
return
impl
::
get_weight_decay_multiplier
(
obj
,
special_
());
}
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
namespace
impl
...
@@ -893,6 +914,7 @@ namespace dlib
...
@@ -893,6 +914,7 @@ namespace dlib
temp_tensor
.
clear
();
temp_tensor
.
clear
();
gradient_input_is_stale
=
true
;
gradient_input_is_stale
=
true
;
subnetwork
->
clean
();
subnetwork
->
clean
();
call_clean_method_if_exists
(
details
);
}
}
friend
void
serialize
(
const
add_layer
&
item
,
std
::
ostream
&
out
)
friend
void
serialize
(
const
add_layer
&
item
,
std
::
ostream
&
out
)
...
@@ -1255,6 +1277,7 @@ namespace dlib
...
@@ -1255,6 +1277,7 @@ namespace dlib
params_grad
.
clear
();
params_grad
.
clear
();
temp_tensor
.
clear
();
temp_tensor
.
clear
();
gradient_input_is_stale
=
true
;
gradient_input_is_stale
=
true
;
call_clean_method_if_exists
(
details
);
}
}
friend
void
serialize
(
const
add_layer
&
item
,
std
::
ostream
&
out
)
friend
void
serialize
(
const
add_layer
&
item
,
std
::
ostream
&
out
)
...
@@ -3475,6 +3498,71 @@ namespace dlib
...
@@ -3475,6 +3498,71 @@ namespace dlib
impl
::
vl_loop_backwards
<
begin
,
end
>::
visit
(
net
,
v
);
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
);
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
}
...
...
dlib/dnn/core_abstract.h
View file @
3a91295e
...
@@ -562,6 +562,8 @@ namespace dlib
...
@@ -562,6 +562,8 @@ namespace dlib
clean(). The purpose of clean() is to compact the network object prior
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
to saving it to disk so that it takes up less space and the IO is
quicker.
quicker.
- This also calls the .clean() method on any layer details objects that
define a .clean() method.
!*/
!*/
};
};
...
@@ -1578,6 +1580,38 @@ namespace dlib
...
@@ -1578,6 +1580,38 @@ namespace dlib
v(i-1, layer<i-1>(net));
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
struct
layer_test_results
...
...
dlib/dnn/cuda_dlib.cu
View file @
3a91295e
...
@@ -261,6 +261,57 @@ namespace dlib
...
@@ -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
)
__global__
void
_cuda_multiply1
(
float
*
d
,
const
float
*
s1
,
const
float
*
s2
,
size_t
n
)
...
@@ -1085,7 +1136,8 @@ namespace dlib
...
@@ -1085,7 +1136,8 @@ namespace dlib
grad
.
device
(),
src
.
device
(),
gradient_input
.
device
(),
grad
.
size
(),
grad
.
device
(),
src
.
device
(),
gradient_input
.
device
(),
grad
.
size
(),
param
.
device
(),
params_grad
.
device
());
param
.
device
(),
params_grad
.
device
());
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
void
copy_tensor
(
void
copy_tensor
(
tensor
&
dest
,
tensor
&
dest
,
...
@@ -1117,6 +1169,7 @@ namespace dlib
...
@@ -1117,6 +1169,7 @@ namespace dlib
src_p
+=
src_sample_size
;
src_p
+=
src_sample_size
;
}
}
}
}
// ----------------------------------------------------------------------------------------
// ----------------------------------------------------------------------------------------
}
}
...
...
dlib/dnn/cuda_dlib.h
View file @
3a91295e
...
@@ -142,6 +142,21 @@ namespace dlib
...
@@ -142,6 +142,21 @@ namespace dlib
const
tensor
&
v2
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
(
void
set_tensor
(
...
...
dlib/dnn/curand_dlibapi.cpp
View file @
3a91295e
...
@@ -91,6 +91,17 @@ namespace dlib
...
@@ -91,6 +91,17 @@ namespace dlib
CHECK_CURAND
(
curandGenerateUniform
((
curandGenerator_t
)
handle
,
data
.
device
(),
data
.
size
()));
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
()));
}
// -----------------------------------------------------------------------------------
// -----------------------------------------------------------------------------------
}
}
...
...
Prev
1
2
3
4
5
…
7
Next
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment