Commit d3929cb0 authored by Rostyslav Geyyer's avatar Rostyslav Geyyer
Browse files

Format

parent 6f0735f5
...@@ -1108,9 +1108,7 @@ inline __host__ __device__ constexpr bhalf_t bf16_convert_rtn<bhalf_t, half_t>(h ...@@ -1108,9 +1108,7 @@ inline __host__ __device__ constexpr bhalf_t bf16_convert_rtn<bhalf_t, half_t>(h
// Pseudo random number generator // Pseudo random number generator
// version for fp32 // version for fp32
template <typename T, template <typename T, uint32_t seed, std::enable_if_t<std::is_same<float, T>{}, bool> = false>
uint32_t seed,
std::enable_if_t<std::is_same<float, T>{}, bool> = false>
__host__ __device__ uint32_t prand_generator(index_t id, T val) __host__ __device__ uint32_t prand_generator(index_t id, T val)
{ {
uint32_t x = reinterpret_cast<uint32_t&>(val); uint32_t x = reinterpret_cast<uint32_t&>(val);
...@@ -1119,15 +1117,14 @@ __host__ __device__ uint32_t prand_generator(index_t id, T val) ...@@ -1119,15 +1117,14 @@ __host__ __device__ uint32_t prand_generator(index_t id, T val)
drop_bits = ((drop_bits & 31) << 11) | (drop_bits >> 5); drop_bits = ((drop_bits & 31) << 11) | (drop_bits >> 5);
drop_bits *= 0x7000149; drop_bits *= 0x7000149;
// NOTE: If id is in 64 bit, we are only using lower 32 bit. // NOTE: If id is in 64 bit, we are only using lower 32 bit.
// So, it can have an effect of using same id for multiple elements when the id is very large! // So, it can have an effect of using same id for multiple elements when the id is very
// large!
uint32_t rng = (drop_bits ^ 0x13371337 ^ (id * 229791) ^ seed); uint32_t rng = (drop_bits ^ 0x13371337 ^ (id * 229791) ^ seed);
return rng; return rng;
} }
// version for fp16 // version for fp16
template <typename T, template <typename T, uint32_t seed, std::enable_if_t<std::is_same<half_t, T>{}, bool> = false>
uint32_t seed,
std::enable_if_t<std::is_same<half_t, T>{}, bool> = false>
__host__ __device__ uint32_t prand_generator(index_t id, T val) __host__ __device__ uint32_t prand_generator(index_t id, T val)
{ {
uint16_t x = reinterpret_cast<uint16_t&>(val); uint16_t x = reinterpret_cast<uint16_t&>(val);
...@@ -1135,7 +1132,8 @@ __host__ __device__ uint32_t prand_generator(index_t id, T val) ...@@ -1135,7 +1132,8 @@ __host__ __device__ uint32_t prand_generator(index_t id, T val)
drop_bits = ((drop_bits & 31) << 11) | (drop_bits >> 5); drop_bits = ((drop_bits & 31) << 11) | (drop_bits >> 5);
drop_bits *= 0x7000149; drop_bits *= 0x7000149;
// NOTE: If id is in 64 bit, we are only using lower 32 bit. // NOTE: If id is in 64 bit, we are only using lower 32 bit.
// So, it can have an effect of using same id for multiple elements when the id is very large! // So, it can have an effect of using same id for multiple elements when the id is very
// large!
uint32_t rng = (drop_bits ^ 0x13371337 ^ (id * 229791) ^ seed); uint32_t rng = (drop_bits ^ 0x13371337 ^ (id * 229791) ^ seed);
return rng; return rng;
} }
......
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