diff options
author | A. Unique TensorFlower <nobody@tensorflow.org> | 2016-05-02 09:41:17 -0800 |
---|---|---|
committer | TensorFlower Gardener <gardener@tensorflow.org> | 2016-05-02 10:51:59 -0700 |
commit | 6855bcc08cfcbba1a20699b3d53458a490cde2a8 (patch) | |
tree | a868810d009ad40e96bf6a7a9dafe0a19eb42a12 /tensorflow/core/lib/random | |
parent | 665d1c31df6fd9d637f31904cbb7a368c822707c (diff) |
tensorflow: refine PhiloxRandomOp cost
Currently PhiloxRandomOp says that cost of generating
4 numbers is 4. This is way too far from reality.
RandomUniform cost is ~55 cycles per group, RandomNormal -- ~331 cycles,
TruncatedNormal -- ~392 cycles.
This new model predicts cost as 52, 320 and 400, respectively.
This is required for better parallelization in Shard.
random_op_test benchmarks do not show any change with current Shard.
TESTED:
- passed opensource_build
http://ci.tensorflow.org/job/tensorflow-cl-multijob/1274/
Change: 121285968
Diffstat (limited to 'tensorflow/core/lib/random')
-rw-r--r-- | tensorflow/core/lib/random/philox_random.h | 2 | ||||
-rw-r--r-- | tensorflow/core/lib/random/random_distributions.h | 22 |
2 files changed, 24 insertions, 0 deletions
diff --git a/tensorflow/core/lib/random/philox_random.h b/tensorflow/core/lib/random/philox_random.h index dc8de09d2c..3e53eeae33 100644 --- a/tensorflow/core/lib/random/philox_random.h +++ b/tensorflow/core/lib/random/philox_random.h @@ -105,6 +105,8 @@ class PhiloxRandom { typedef uint32 ResultElementType; // 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; PHILOX_DEVICE_INLINE PhiloxRandom() {} diff --git a/tensorflow/core/lib/random/random_distributions.h b/tensorflow/core/lib/random/random_distributions.h index e81d25237c..c12e1b2b60 100644 --- a/tensorflow/core/lib/random/random_distributions.h +++ b/tensorflow/core/lib/random/random_distributions.h @@ -52,6 +52,8 @@ class UniformDistribution<Generator, Eigen::half> { public: // The number of elements that will be returned. static const int kResultElementCount = Generator::kResultElementCount; + // Cost of generation of a single element (in cycles). + static const int kElementCost = 3; // Indicate that this distribution may take variable number of samples // during the runtime. static const bool kVariableSamplesPerOutput = false; @@ -74,6 +76,8 @@ class UniformDistribution<Generator, float> { public: // The number of elements that will be returned. static const int kResultElementCount = Generator::kResultElementCount; + // Cost of generation of a single element (in cycles). + static const int kElementCost = 3; // Indicate that this distribution may take variable number of samples // during the runtime. static const bool kVariableSamplesPerOutput = false; @@ -96,6 +100,8 @@ class UniformDistribution<Generator, double> { public: // The number of elements that will be returned. static const int kResultElementCount = Generator::kResultElementCount / 2; + // Cost of generation of a single element (in cycles). + static const int kElementCost = 3; // Indicate that this distribution may take variable number of samples // during the runtime. static const bool kVariableSamplesPerOutput = false; @@ -118,6 +124,8 @@ class UniformDistribution<Generator, int32> { public: // The number of elements that will be returned. static const int kResultElementCount = Generator::kResultElementCount; + // Cost of generation of a single element (in cycles). + static const int kElementCost = 3; // Indicate that this distribution may take variable number of samples // during the runtime. static const bool kVariableSamplesPerOutput = false; @@ -150,6 +158,8 @@ class UniformDistribution<Generator, int64> { public: // The number of elements that will be returned. static const int kResultElementCount = Generator::kResultElementCount / 2; + // Cost of generation of a single element (in cycles). + static const int kElementCost = 3; // Indicate that this distribution may take variable number of samples // during the runtime. static const bool kVariableSamplesPerOutput = false; @@ -239,6 +249,8 @@ class NormalDistribution<Generator, Eigen::half> { public: // The number of elements that will be returned. static const int kResultElementCount = Generator::kResultElementCount; + // Cost of generation of a single element (in cycles). + static const int kElementCost = 70; // Indicate that this distribution may take variable number of samples // during the runtime. static const bool kVariableSamplesPerOutput = false; @@ -264,6 +276,8 @@ class NormalDistribution<Generator, float> { public: // The number of elements that will be returned. static const int kResultElementCount = Generator::kResultElementCount; + // Cost of generation of a single element (in cycles). + static const int kElementCost = 70; // Indicate that this distribution may take variable number of samples // during the runtime. static const bool kVariableSamplesPerOutput = false; @@ -286,6 +300,8 @@ class NormalDistribution<Generator, double> { public: // The number of elements that will be returned. static const int kResultElementCount = Generator::kResultElementCount / 2; + // Cost of generation of a single element (in cycles). + static const int kElementCost = 70; // Indicate that this distribution may take variable number of samples // during the runtime. static const bool kVariableSamplesPerOutput = false; @@ -328,6 +344,8 @@ class TruncatedNormalDistribution<SingleSampleGenerator, Eigen::half> { // The number of elements that will be returned. static const int kResultElementCount = SingleSampleGenerator::kNativeElementCount; + // Cost of generation of a single element (in cycles). + static const int kElementCost = 90; // Indicate that this distribution may take variable number of samples // during the runtime. static const bool kVariableSamplesPerOutput = true; @@ -369,6 +387,8 @@ class TruncatedNormalDistribution<SingleSampleGenerator, float> { // The number of elements that will be returned. static const int kResultElementCount = SingleSampleGenerator::kNativeElementCount; + // Cost of generation of a single element (in cycles). + static const int kElementCost = 90; // Indicate that this distribution may take variable number of samples // during the runtime. static const bool kVariableSamplesPerOutput = true; @@ -412,6 +432,8 @@ class TruncatedNormalDistribution<SingleSampleGenerator, double> { (SingleSampleGenerator::kNativeElementCount > 1) ? SingleSampleGenerator::kNativeElementCount / 2 : 1; + // Cost of generation of a single element (in cycles). + static const int kElementCost = 90; // Indicate that this distribution may take variable number of samples // during the runtime. static const bool kVariableSamplesPerOutput = true; |