Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
D
dlib
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
钟尚武
dlib
Commits
f6ece5d2
Commit
f6ece5d2
authored
Jan 30, 2017
by
Davis King
Browse files
Options
Browse Files
Download
Plain Diff
merged
parents
bdbf7bb8
4dfeb7e1
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
28 additions
and
27 deletions
+28
-27
tensor.h
dlib/dnn/tensor.h
+3
-3
tensor_abstract.h
dlib/dnn/tensor_abstract.h
+2
-2
matrix.h
dlib/matrix/matrix.h
+3
-7
thread_pool_extension.cpp
dlib/threads/thread_pool_extension.cpp
+6
-4
thread_pool_extension.h
dlib/threads/thread_pool_extension.h
+4
-1
threads_kernel_shared.cpp
dlib/threads/threads_kernel_shared.cpp
+10
-10
No files found.
dlib/dnn/tensor.h
View file @
f6ece5d2
...
...
@@ -615,7 +615,7 @@ namespace dlib
alias_tensor_instance
operator
()
(
tensor
&
t
,
size_t
offset
)
)
const
{
DLIB_CASSERT
(
offset
+
size
()
<=
t
.
size
());
...
...
@@ -637,7 +637,7 @@ namespace dlib
alias_tensor_const_instance
operator
()
(
const
tensor
&
t
,
size_t
offset
)
)
const
{
alias_tensor_const_instance
temp
;
temp
.
inst
=
(
*
this
)(
const_cast
<
tensor
&>
(
t
),
offset
);
...
...
@@ -645,7 +645,7 @@ namespace dlib
}
private
:
alias_tensor_instance
inst
;
mutable
alias_tensor_instance
inst
;
};
inline
void
serialize
(
const
alias_tensor
&
item
,
std
::
ostream
&
out
)
...
...
dlib/dnn/tensor_abstract.h
View file @
f6ece5d2
...
...
@@ -663,7 +663,7 @@ namespace dlib
alias_tensor_instance
operator
()
(
tensor
&
t
,
size_t
offset
);
)
const
;
/*!
requires
- offset+size() <= t.size()
...
...
@@ -684,7 +684,7 @@ namespace dlib
alias_tensor_const_instance
operator
()
(
const
tensor
&
t
,
size_t
offset
);
)
const
;
/*!
requires
- offset+size() <= t.size()
...
...
dlib/matrix/matrix.h
View file @
f6ece5d2
...
...
@@ -1812,13 +1812,9 @@ namespace dlib
)
{
// assign the given value to every spot in this matrix
for
(
long
r
=
0
;
r
<
nr
();
++
r
)
{
for
(
long
c
=
0
;
c
<
nc
();
++
c
)
{
data
(
r
,
c
)
=
val
;
}
}
const
long
size
=
nr
()
*
nc
();
for
(
long
i
=
0
;
i
<
size
;
++
i
)
data
(
i
)
=
val
;
// Now return the literal_assign_helper so that the user
// can use the overloaded comma notation to initialize
...
...
dlib/threads/thread_pool_extension.cpp
View file @
f6ece5d2
...
...
@@ -19,12 +19,11 @@ namespace dlib
we_are_destructing
(
false
)
{
tasks
.
resize
(
num_threads
);
threads
.
resize
(
num_threads
);
for
(
unsigned
long
i
=
0
;
i
<
num_threads
;
++
i
)
{
register_thread
(
*
this
,
&
thread_pool_implementation
::
thread
);
threads
[
i
]
=
std
::
thread
([
&
](){
this
->
thread
();}
);
}
start
();
}
// ----------------------------------------------------------------------------------------
...
...
@@ -60,7 +59,10 @@ namespace dlib
task_ready_signaler
.
broadcast
();
}
wait
();
// wait for all threads to terminate
for
(
auto
&
t
:
threads
)
t
.
join
();
threads
.
clear
();
// Throw any unhandled exceptions. Since shutdown_pool() is only called in the
// destructor this will kill the program.
...
...
dlib/threads/thread_pool_extension.h
View file @
f6ece5d2
...
...
@@ -14,6 +14,7 @@
#include "../smart_pointers_thread_safe.h"
#include "../smart_pointers.h"
#include <exception>
#include <thread>
namespace
dlib
{
...
...
@@ -126,7 +127,7 @@ namespace dlib
// ----------------------------------------------------------------------------------------
class
thread_pool_implementation
:
private
multithreaded_object
class
thread_pool_implementation
{
/*!
CONVENTION
...
...
@@ -474,6 +475,8 @@ namespace dlib
signaler
task_ready_signaler
;
bool
we_are_destructing
;
std
::
vector
<
std
::
thread
>
threads
;
// restricted functions
thread_pool_implementation
(
thread_pool_implementation
&
);
// copy constructor
thread_pool_implementation
&
operator
=
(
thread_pool_implementation
&
);
// assignment operator
...
...
dlib/threads/threads_kernel_shared.cpp
View file @
f6ece5d2
...
...
@@ -39,15 +39,6 @@ namespace dlib
bool
thread_pool_has_been_destroyed
=
false
;
// ----------------------------------------------------------------------------------------
threader
&
thread_pool
(
)
{
static
threader
*
thread_pool
=
new
threader
;
return
*
thread_pool
;
}
// ----------------------------------------------------------------------------------------
struct
threader_destruct_helper
...
...
@@ -59,7 +50,16 @@ namespace dlib
thread_pool
().
destruct_if_ready
();
}
};
static
threader_destruct_helper
a
;
// ----------------------------------------------------------------------------------------
threader
&
thread_pool
(
)
{
static
threader
*
thread_pool
=
new
threader
;
static
threader_destruct_helper
a
;
return
*
thread_pool
;
}
// ----------------------------------------------------------------------------------------
...
...
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