aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/lib/random
diff options
context:
space:
mode:
authorGravatar Geoffrey Irving <geoffreyi@google.com>2017-04-07 10:25:45 -0800
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2017-04-07 11:45:22 -0700
commit54dfebaa68cfb4e7e5703e8bbfd866f45abfee54 (patch)
tree382a0b60e11ee38e06101b07a242db8465121673 /tensorflow/core/lib/random
parent0cb8adae19ef79b6f1a5cf8f41be7a172277934d (diff)
Move a few random op helper functions to header files
1. shape_inference::RandomShape 2. OpKernel::MakeShape(Tensor, TensorShape*) Change: 152522156
Diffstat (limited to 'tensorflow/core/lib/random')
-rw-r--r--tensorflow/core/lib/random/philox_random.h14
1 files changed, 8 insertions, 6 deletions
diff --git a/tensorflow/core/lib/random/philox_random.h b/tensorflow/core/lib/random/philox_random.h
index 1fec5a3b44..b2adb4462b 100644
--- a/tensorflow/core/lib/random/philox_random.h
+++ b/tensorflow/core/lib/random/philox_random.h
@@ -101,12 +101,15 @@ class Array {
// 2. PhiloxRandom is compilable by gcc and nvcc.
class PhiloxRandom {
public:
- typedef Array<uint32, 4> ResultType;
- typedef uint32 ResultElementType;
+ using ResultType = Array<uint32, 4>;
+ using ResultElementType = uint32;
// The number of elements that will be returned.
static const int kResultElementCount = 4;
// Cost of generation of a single element (in cycles).
static const int kElementCost = 10;
+ // The type for the 64-bit key stored in the form of two 32-bit uint
+ // that are used in the diffusion process.
+ using Key = Array<uint32, 2>;
PHILOX_DEVICE_INLINE
PhiloxRandom() {}
@@ -125,6 +128,9 @@ class PhiloxRandom {
counter_[3] = static_cast<uint32>(seed_hi >> 32);
}
+ PHILOX_DEVICE_INLINE
+ PhiloxRandom(ResultType counter, Key key) : counter_(counter), key_(key) {}
+
// Skip the specified number of samples of 128-bits in the current stream.
PHILOX_DEVICE_INLINE
void Skip(uint64 count) {
@@ -178,10 +184,6 @@ class PhiloxRandom {
}
private:
- // The type for the 64-bit key stored in the form of two 32-bit uint
- // that are used in the diffusion process.
- typedef Array<uint32, 2> Key;
-
// We use the same constants as recommended by the original paper.
static const uint32 kPhiloxW32A = 0x9E3779B9;
static const uint32 kPhiloxW32B = 0xBB67AE85;