| 370 | |
| 371 | template <typename T> |
| 372 | __global__ void FillWithRandomNumbersKernel( |
| 373 | GpuMatView<T> output, |
| 374 | GpuMatView<curandState> random_state, |
| 375 | const T min_value, |
| 376 | const T max_value) { |
| 377 | const size_t row = blockIdx.y * blockDim.y + threadIdx.y; |
| 378 | const size_t col = blockIdx.x * blockDim.x + threadIdx.x; |
| 379 | if (row < output.GetHeight() && col < output.GetWidth()) { |
| 380 | curandState local_state = random_state.Get(row, col); |
| 381 | for (size_t slice = 0; slice < output.GetDepth(); ++slice) { |
| 382 | const T random_value = |
| 383 | curand_uniform(&local_state) * (max_value - min_value) + min_value; |
| 384 | output.Set(row, col, slice, random_value); |
| 385 | } |
| 386 | random_state.Set(row, col, local_state); |
| 387 | } |
| 388 | } |
| 389 | |
| 390 | } // namespace internal |
| 391 | |