|
|
|
@ -71,12 +71,12 @@ template <class Generator>
|
|
|
|
|
class UniformDistribution<Generator, Eigen::half> {
|
|
|
|
|
public:
|
|
|
|
|
// The number of elements that will be returned.
|
|
|
|
|
static const int kResultElementCount = Generator::kResultElementCount;
|
|
|
|
|
static constexpr int kResultElementCount = Generator::kResultElementCount;
|
|
|
|
|
// Cost of generation of a single element (in cycles).
|
|
|
|
|
static const int kElementCost = 3;
|
|
|
|
|
static constexpr int kElementCost = 3;
|
|
|
|
|
// Indicate that this distribution may take variable number of samples
|
|
|
|
|
// during the runtime.
|
|
|
|
|
static const bool kVariableSamplesPerOutput = false;
|
|
|
|
|
static constexpr bool kVariableSamplesPerOutput = false;
|
|
|
|
|
typedef Array<Eigen::half, kResultElementCount> ResultType;
|
|
|
|
|
typedef Eigen::half ResultElementType;
|
|
|
|
|
|
|
|
|
@ -95,12 +95,12 @@ template <class Generator>
|
|
|
|
|
class UniformDistribution<Generator, bfloat16> {
|
|
|
|
|
public:
|
|
|
|
|
// The number of elements that will be returned.
|
|
|
|
|
static const int kResultElementCount = Generator::kResultElementCount;
|
|
|
|
|
static constexpr int kResultElementCount = Generator::kResultElementCount;
|
|
|
|
|
// Cost of generation of a single element (in cycles).
|
|
|
|
|
static const int kElementCost = 3;
|
|
|
|
|
static constexpr int kElementCost = 3;
|
|
|
|
|
// Indicate that this distribution may take variable number of samples
|
|
|
|
|
// during the runtime.
|
|
|
|
|
static const bool kVariableSamplesPerOutput = false;
|
|
|
|
|
static constexpr bool kVariableSamplesPerOutput = false;
|
|
|
|
|
typedef Array<bfloat16, kResultElementCount> ResultType;
|
|
|
|
|
typedef bfloat16 ResultElementType;
|
|
|
|
|
|
|
|
|
@ -119,12 +119,12 @@ template <class Generator>
|
|
|
|
|
class UniformDistribution<Generator, float> {
|
|
|
|
|
public:
|
|
|
|
|
// The number of elements that will be returned.
|
|
|
|
|
static const int kResultElementCount = Generator::kResultElementCount;
|
|
|
|
|
static constexpr int kResultElementCount = Generator::kResultElementCount;
|
|
|
|
|
// Cost of generation of a single element (in cycles).
|
|
|
|
|
static const int kElementCost = 3;
|
|
|
|
|
static constexpr int kElementCost = 3;
|
|
|
|
|
// Indicate that this distribution may take variable number of samples
|
|
|
|
|
// during the runtime.
|
|
|
|
|
static const bool kVariableSamplesPerOutput = false;
|
|
|
|
|
static constexpr bool kVariableSamplesPerOutput = false;
|
|
|
|
|
typedef Array<float, kResultElementCount> ResultType;
|
|
|
|
|
typedef float ResultElementType;
|
|
|
|
|
|
|
|
|
@ -143,12 +143,12 @@ template <class Generator>
|
|
|
|
|
class UniformDistribution<Generator, double> {
|
|
|
|
|
public:
|
|
|
|
|
// The number of elements that will be returned.
|
|
|
|
|
static const int kResultElementCount = Generator::kResultElementCount / 2;
|
|
|
|
|
static constexpr int kResultElementCount = Generator::kResultElementCount / 2;
|
|
|
|
|
// Cost of generation of a single element (in cycles).
|
|
|
|
|
static const int kElementCost = 3;
|
|
|
|
|
static constexpr int kElementCost = 3;
|
|
|
|
|
// Indicate that this distribution may take variable number of samples
|
|
|
|
|
// during the runtime.
|
|
|
|
|
static const bool kVariableSamplesPerOutput = false;
|
|
|
|
|
static constexpr bool kVariableSamplesPerOutput = false;
|
|
|
|
|
typedef Array<double, kResultElementCount> ResultType;
|
|
|
|
|
typedef double ResultElementType;
|
|
|
|
|
|
|
|
|
@ -167,12 +167,12 @@ template <class Generator>
|
|
|
|
|
class UniformDistribution<Generator, int32> {
|
|
|
|
|
public:
|
|
|
|
|
// The number of elements that will be returned.
|
|
|
|
|
static const int kResultElementCount = Generator::kResultElementCount;
|
|
|
|
|
static constexpr int kResultElementCount = Generator::kResultElementCount;
|
|
|
|
|
// Cost of generation of a single element (in cycles).
|
|
|
|
|
static const int kElementCost = 3;
|
|
|
|
|
static constexpr int kElementCost = 3;
|
|
|
|
|
// Indicate that this distribution may take variable number of samples
|
|
|
|
|
// during the runtime.
|
|
|
|
|
static const bool kVariableSamplesPerOutput = false;
|
|
|
|
|
static constexpr bool kVariableSamplesPerOutput = false;
|
|
|
|
|
typedef Array<int32, kResultElementCount> ResultType;
|
|
|
|
|
typedef int32 ResultElementType;
|
|
|
|
|
|
|
|
|
@ -202,12 +202,12 @@ template <class Generator>
|
|
|
|
|
class UniformDistribution<Generator, int64> {
|
|
|
|
|
public:
|
|
|
|
|
// The number of elements that will be returned.
|
|
|
|
|
static const int kResultElementCount = Generator::kResultElementCount / 2;
|
|
|
|
|
static constexpr int kResultElementCount = Generator::kResultElementCount / 2;
|
|
|
|
|
// Cost of generation of a single element (in cycles).
|
|
|
|
|
static const int kElementCost = 3;
|
|
|
|
|
static constexpr int kElementCost = 3;
|
|
|
|
|
// Indicate that this distribution may take variable number of samples
|
|
|
|
|
// during the runtime.
|
|
|
|
|
static const bool kVariableSamplesPerOutput = false;
|
|
|
|
|
static constexpr bool kVariableSamplesPerOutput = false;
|
|
|
|
|
typedef Array<int64, kResultElementCount> ResultType;
|
|
|
|
|
typedef int64 ResultElementType;
|
|
|
|
|
|
|
|
|
@ -244,12 +244,12 @@ template <typename Generator, typename IntType>
|
|
|
|
|
class UniformFullIntDistribution32 {
|
|
|
|
|
public:
|
|
|
|
|
// The number of elements that will be returned.
|
|
|
|
|
static const int kResultElementCount = Generator::kResultElementCount;
|
|
|
|
|
static constexpr int kResultElementCount = Generator::kResultElementCount;
|
|
|
|
|
// Cost of generation of a single element (in cycles).
|
|
|
|
|
static const int kElementCost = 3;
|
|
|
|
|
static constexpr int kElementCost = 3;
|
|
|
|
|
// Indicate that this distribution may take variable number of samples
|
|
|
|
|
// during the runtime.
|
|
|
|
|
static const bool kVariableSamplesPerOutput = false;
|
|
|
|
|
static constexpr bool kVariableSamplesPerOutput = false;
|
|
|
|
|
typedef Array<IntType, kResultElementCount> ResultType;
|
|
|
|
|
typedef IntType ResultElementType;
|
|
|
|
|
|
|
|
|
@ -268,12 +268,12 @@ template <typename Generator, typename IntType>
|
|
|
|
|
class UniformFullIntDistribution64 {
|
|
|
|
|
public:
|
|
|
|
|
// The number of elements that will be returned.
|
|
|
|
|
static const int kResultElementCount = Generator::kResultElementCount / 2;
|
|
|
|
|
static constexpr int kResultElementCount = Generator::kResultElementCount / 2;
|
|
|
|
|
// Cost of generation of a single element (in cycles).
|
|
|
|
|
static const int kElementCost = 3;
|
|
|
|
|
static constexpr int kElementCost = 3;
|
|
|
|
|
// Indicate that this distribution may take variable number of samples
|
|
|
|
|
// during the runtime.
|
|
|
|
|
static const bool kVariableSamplesPerOutput = false;
|
|
|
|
|
static constexpr bool kVariableSamplesPerOutput = false;
|
|
|
|
|
typedef Array<IntType, kResultElementCount> ResultType;
|
|
|
|
|
typedef IntType ResultElementType;
|
|
|
|
|
|
|
|
|
@ -307,9 +307,9 @@ template <class Generator>
|
|
|
|
|
class SingleSampleAdapter {
|
|
|
|
|
public:
|
|
|
|
|
// The number of elements that will be returned.
|
|
|
|
|
static const int kResultElementCount = 1;
|
|
|
|
|
static constexpr int kResultElementCount = 1;
|
|
|
|
|
// The number of elements that will be returned by the underlying generator.
|
|
|
|
|
static const int kNativeElementCount = Generator::kResultElementCount;
|
|
|
|
|
static constexpr int kNativeElementCount = Generator::kResultElementCount;
|
|
|
|
|
typedef typename Generator::ResultElementType ResultType;
|
|
|
|
|
typedef typename Generator::ResultElementType ResultElementType;
|
|
|
|
|
|
|
|
|
@ -391,12 +391,12 @@ template <class Generator>
|
|
|
|
|
class NormalDistribution<Generator, Eigen::half> {
|
|
|
|
|
public:
|
|
|
|
|
// The number of elements that will be returned.
|
|
|
|
|
static const int kResultElementCount = Generator::kResultElementCount;
|
|
|
|
|
static constexpr int kResultElementCount = Generator::kResultElementCount;
|
|
|
|
|
// Cost of generation of a single element (in cycles).
|
|
|
|
|
static const int kElementCost = 70;
|
|
|
|
|
static constexpr int kElementCost = 70;
|
|
|
|
|
// Indicate that this distribution may take variable number of samples
|
|
|
|
|
// during the runtime.
|
|
|
|
|
static const bool kVariableSamplesPerOutput = false;
|
|
|
|
|
static constexpr bool kVariableSamplesPerOutput = false;
|
|
|
|
|
typedef Array<Eigen::half, kResultElementCount> ResultType;
|
|
|
|
|
typedef Eigen::half ResultElementType;
|
|
|
|
|
|
|
|
|
@ -418,12 +418,12 @@ template <class Generator>
|
|
|
|
|
class NormalDistribution<Generator, bfloat16> {
|
|
|
|
|
public:
|
|
|
|
|
// The number of elements that will be returned.
|
|
|
|
|
static const int kResultElementCount = Generator::kResultElementCount;
|
|
|
|
|
static constexpr int kResultElementCount = Generator::kResultElementCount;
|
|
|
|
|
// Cost of generation of a single element (in cycles).
|
|
|
|
|
static const int kElementCost = 70;
|
|
|
|
|
static constexpr int kElementCost = 70;
|
|
|
|
|
// Indicate that this distribution may take variable number of samples
|
|
|
|
|
// during the runtime.
|
|
|
|
|
static const bool kVariableSamplesPerOutput = false;
|
|
|
|
|
static constexpr bool kVariableSamplesPerOutput = false;
|
|
|
|
|
typedef Array<bfloat16, kResultElementCount> ResultType;
|
|
|
|
|
typedef bfloat16 ResultElementType;
|
|
|
|
|
|
|
|
|
@ -448,12 +448,12 @@ template <class Generator>
|
|
|
|
|
class NormalDistribution<Generator, float> {
|
|
|
|
|
public:
|
|
|
|
|
// The number of elements that will be returned.
|
|
|
|
|
static const int kResultElementCount = Generator::kResultElementCount;
|
|
|
|
|
static constexpr int kResultElementCount = Generator::kResultElementCount;
|
|
|
|
|
// Cost of generation of a single element (in cycles).
|
|
|
|
|
static const int kElementCost = 70;
|
|
|
|
|
static constexpr int kElementCost = 70;
|
|
|
|
|
// Indicate that this distribution may take variable number of samples
|
|
|
|
|
// during the runtime.
|
|
|
|
|
static const bool kVariableSamplesPerOutput = false;
|
|
|
|
|
static constexpr bool kVariableSamplesPerOutput = false;
|
|
|
|
|
typedef Array<float, kResultElementCount> ResultType;
|
|
|
|
|
typedef float ResultElementType;
|
|
|
|
|
|
|
|
|
@ -472,12 +472,12 @@ template <class Generator>
|
|
|
|
|
class NormalDistribution<Generator, double> {
|
|
|
|
|
public:
|
|
|
|
|
// The number of elements that will be returned.
|
|
|
|
|
static const int kResultElementCount = Generator::kResultElementCount / 2;
|
|
|
|
|
static constexpr int kResultElementCount = Generator::kResultElementCount / 2;
|
|
|
|
|
// Cost of generation of a single element (in cycles).
|
|
|
|
|
static const int kElementCost = 70;
|
|
|
|
|
static constexpr int kElementCost = 70;
|
|
|
|
|
// Indicate that this distribution may take variable number of samples
|
|
|
|
|
// during the runtime.
|
|
|
|
|
static const bool kVariableSamplesPerOutput = false;
|
|
|
|
|
static constexpr bool kVariableSamplesPerOutput = false;
|
|
|
|
|
typedef Array<double, kResultElementCount> ResultType;
|
|
|
|
|
typedef double ResultElementType;
|
|
|
|
|
|
|
|
|
@ -515,13 +515,13 @@ template <class SingleSampleGenerator>
|
|
|
|
|
class TruncatedNormalDistribution<SingleSampleGenerator, Eigen::half> {
|
|
|
|
|
public:
|
|
|
|
|
// The number of elements that will be returned.
|
|
|
|
|
static const int kResultElementCount =
|
|
|
|
|
static constexpr int kResultElementCount =
|
|
|
|
|
SingleSampleGenerator::kNativeElementCount;
|
|
|
|
|
// Cost of generation of a single element (in cycles).
|
|
|
|
|
static const int kElementCost = 90;
|
|
|
|
|
static constexpr int kElementCost = 90;
|
|
|
|
|
// Indicate that this distribution may take variable number of samples
|
|
|
|
|
// during the runtime.
|
|
|
|
|
static const bool kVariableSamplesPerOutput = true;
|
|
|
|
|
static constexpr bool kVariableSamplesPerOutput = true;
|
|
|
|
|
// The threshold where the normal distribution is truncated.
|
|
|
|
|
const float kTruncateValue = 2.0f;
|
|
|
|
|
|
|
|
|
@ -561,13 +561,13 @@ template <class SingleSampleGenerator>
|
|
|
|
|
class TruncatedNormalDistribution<SingleSampleGenerator, bfloat16> {
|
|
|
|
|
public:
|
|
|
|
|
// The number of elements that will be returned.
|
|
|
|
|
static const int kResultElementCount =
|
|
|
|
|
static constexpr int kResultElementCount =
|
|
|
|
|
SingleSampleGenerator::kNativeElementCount;
|
|
|
|
|
// Cost of generation of a single element (in cycles).
|
|
|
|
|
static const int kElementCost = 90;
|
|
|
|
|
static constexpr int kElementCost = 90;
|
|
|
|
|
// Indicate that this distribution may take variable number of samples
|
|
|
|
|
// during the runtime.
|
|
|
|
|
static const bool kVariableSamplesPerOutput = true;
|
|
|
|
|
static constexpr bool kVariableSamplesPerOutput = true;
|
|
|
|
|
// The threshold where the normal distribution is truncated.
|
|
|
|
|
const float kTruncateValue = 2.0f;
|
|
|
|
|
|
|
|
|
@ -608,13 +608,13 @@ template <class SingleSampleGenerator>
|
|
|
|
|
class TruncatedNormalDistribution<SingleSampleGenerator, float> {
|
|
|
|
|
public:
|
|
|
|
|
// The number of elements that will be returned.
|
|
|
|
|
static const int kResultElementCount =
|
|
|
|
|
static constexpr int kResultElementCount =
|
|
|
|
|
SingleSampleGenerator::kNativeElementCount;
|
|
|
|
|
// Cost of generation of a single element (in cycles).
|
|
|
|
|
static const int kElementCost = 90;
|
|
|
|
|
static constexpr int kElementCost = 90;
|
|
|
|
|
// Indicate that this distribution may take variable number of samples
|
|
|
|
|
// during the runtime.
|
|
|
|
|
static const bool kVariableSamplesPerOutput = true;
|
|
|
|
|
static constexpr bool kVariableSamplesPerOutput = true;
|
|
|
|
|
// The threshold where the normal distribution is truncated.
|
|
|
|
|
const float kTruncateValue = 2.0f;
|
|
|
|
|
|
|
|
|
@ -655,15 +655,15 @@ template <class SingleSampleGenerator>
|
|
|
|
|
class TruncatedNormalDistribution<SingleSampleGenerator, double> {
|
|
|
|
|
public:
|
|
|
|
|
// The number of elements that will be returned.
|
|
|
|
|
static const int kResultElementCount =
|
|
|
|
|
static constexpr int kResultElementCount =
|
|
|
|
|
(SingleSampleGenerator::kNativeElementCount > 1)
|
|
|
|
|
? SingleSampleGenerator::kNativeElementCount / 2
|
|
|
|
|
: 1;
|
|
|
|
|
// Cost of generation of a single element (in cycles).
|
|
|
|
|
static const int kElementCost = 90;
|
|
|
|
|
static constexpr int kElementCost = 90;
|
|
|
|
|
// Indicate that this distribution may take variable number of samples
|
|
|
|
|
// during the runtime.
|
|
|
|
|
static const bool kVariableSamplesPerOutput = true;
|
|
|
|
|
static constexpr bool kVariableSamplesPerOutput = true;
|
|
|
|
|
typedef Array<double, kResultElementCount> ResultType;
|
|
|
|
|
typedef double ResultElementType;
|
|
|
|
|
const double kTruncateValue = 2.0;
|
|
|
|
|