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
5bc1792d
Commit
5bc1792d
authored
May 31, 2017
by
Davis King
Browse files
Added a .fill() member to curand_generator that can create random 32bit
integers.
parent
2ee10362
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
20 additions
and
0 deletions
+20
-0
dlib/dnn/curand_dlibapi.cpp
dlib/dnn/curand_dlibapi.cpp
+11
-0
dlib/dnn/curand_dlibapi.h
dlib/dnn/curand_dlibapi.h
+9
-0
No files found.
dlib/dnn/curand_dlibapi.cpp
View file @
5bc1792d
...
...
@@ -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
()));
}
// -----------------------------------------------------------------------------------
}
...
...
dlib/dnn/curand_dlibapi.h
View file @
5bc1792d
...
...
@@ -7,6 +7,7 @@
#include "tensor.h"
#include "cuda_errors.h"
#include "cuda_data_ptr.h"
namespace
dlib
{
...
...
@@ -26,6 +27,14 @@ namespace dlib
curand_generator
(
unsigned
long
long
seed
);
~
curand_generator
();
void
fill
(
cuda_data_ptr
<
unsigned
int
>&
data
);
/*!
ensures
- Fills data with random 32-bit unsigned integers.
!*/
void
fill_gaussian
(
tensor
&
data
,
float
mean
=
0
,
...
...
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