@@ -459,13 +459,17 @@ GENERATE_KERNEL1(generate_geometric, real, double p, float, curand_uniform, (Sca
459459#endif
460460
461461#if defined(THC_REAL_IS_LONG) || defined(THC_REAL_IS_DOUBLE) || defined(THC_REAL_IS_FLOAT)
462- #define CURAND64 (STATE ) (((uint64_t )curand(&state[blockIdx .x])) << 32 ) | (uint64_t )curand(&state[blockIdx .x])
463- GENERATE_KERNEL2 (generate_random, real, int32_t base, uint32_t range, uint32_t , curand, (real)(x % range + base))
464- GENERATE_KERNEL2(generate_random_64, real, int64_t base, uint64_t range, uint64_t , CURAND64, (real)(x % range + base))
462+ #define CURAND64 (STATE ) (((uint64_t )curand(STATE)) << 32 ) | (uint64_t )curand(STATE)
463+ GENERATE_KERNEL2 (generate_random, real, int32_t base, uint32_t range, uint32_t , curand, \
464+ static_cast <real>(static_cast <int32_t >((x % range) + base)))
465+ GENERATE_KERNEL2(generate_random_64, real, int64_t base, uint64_t range, uint64_t , CURAND64, \
466+ static_cast <real>(static_cast <int64_t >((x % range) + base)))
465467#elif defined(THC_REAL_IS_HALF)
466- GENERATE_KERNEL2 (generate_random, real, int32_t base, uint32_t range, uint32_t , curand, (ScalarConvert<uint32_t , real>::to(x % range + base)))
468+ GENERATE_KERNEL2 (generate_random, real, int32_t base, uint32_t range, uint32_t , curand,
469+ (ScalarConvert<int32_t , real>::to(static_cast <int32_t >(x % range + base))))
467470#else
468- GENERATE_KERNEL2 (generate_random, real, int32_t base, uint32_t range, uint32_t , curand, (real)(x % range + base))
471+ GENERATE_KERNEL2 (generate_random, real, int32_t base, uint32_t range, uint32_t , curand,
472+ static_cast <real>(static_cast <int32_t >(x % range + base)))
469473#endif
470474
471475THC_API void THCTensor_ (geometric)(THCState* state, THCTensor *self_, double p)
0 commit comments