Skip to content

Commit

Permalink
assert lambda >= 0 in poisson distribution cuda kernel (pytorch#85906)
Browse files Browse the repository at this point in the history
fix pytorch#85731

Pull Request resolved: pytorch#85906
Approved by: https://github.com/ngimel
  • Loading branch information
yuguo68 authored and pytorchmergebot committed Sep 29, 2022
1 parent bc57306 commit c036fb3
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 0 deletions.
1 change: 1 addition & 0 deletions aten/src/ATen/native/cuda/Distributions.cu
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ void poisson_cuda_kernel(
at::PhiloxCudaState philox_args) {
auto functor = [philox_args] __device__(
scalar_t & ret_val, const scalar_t& lambda) {
CUDA_KERNEL_ASSERT(lambda >= 0 && "invalid Poisson rate, expected rate to be non-negative");
auto seeds = at::cuda::philox::unpack(philox_args);
curandStatePhilox4_32_10_t state;
curand_init(std::get<0>(seeds),
Expand Down
2 changes: 2 additions & 0 deletions torch/_torch_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8514,6 +8514,8 @@ def merge_dicts(*dicts):
.. math::
\text{{out}}_i \sim \text{{Poisson}}(\text{{input}}_i)
:attr:`input` must be non-negative.
Args:
input (Tensor): the input tensor containing the rates of the Poisson distribution
Expand Down

0 comments on commit c036fb3

Please sign in to comment.