Commit 5bc1792d authored by Davis King's avatar Davis King

Added a .fill() member to curand_generator that can create random 32bit

integers.
parent 2ee10362
...@@ -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()));
}
// ----------------------------------------------------------------------------------- // -----------------------------------------------------------------------------------
} }
......
...@@ -7,6 +7,7 @@ ...@@ -7,6 +7,7 @@
#include "tensor.h" #include "tensor.h"
#include "cuda_errors.h" #include "cuda_errors.h"
#include "cuda_data_ptr.h"
namespace dlib namespace dlib
{ {
...@@ -26,6 +27,14 @@ namespace dlib ...@@ -26,6 +27,14 @@ namespace dlib
curand_generator(unsigned long long seed); curand_generator(unsigned long long seed);
~curand_generator(); ~curand_generator();
void fill (
cuda_data_ptr<unsigned int>& data
);
/*!
ensures
- Fills data with random 32-bit unsigned integers.
!*/
void fill_gaussian ( void fill_gaussian (
tensor& data, tensor& data,
float mean = 0, float mean = 0,
......
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