Fix boolean scatter and random generation for tensors.

This commit is contained in:
Antonio Sánchez
2025-02-25 21:37:09 +00:00
parent 9935396b15
commit d79bac0d3c
3 changed files with 27 additions and 6 deletions

View File

@@ -49,6 +49,12 @@ EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE T RandomToTypeUniform(uint64_t* state, uin
return static_cast<T>(rnd);
}
template <>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE bool RandomToTypeUniform<bool>(uint64_t* state, uint64_t stream) {
unsigned rnd = PCG_XSH_RS_generator(state, stream);
return (rnd & 0x1) != 0;
}
template <>
EIGEN_DEVICE_FUNC EIGEN_STRONG_INLINE Eigen::half RandomToTypeUniform<Eigen::half>(uint64_t* state, uint64_t stream) {
// Generate 10 random bits for the mantissa, merge with exponent.