File tree Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Expand file tree Collapse file tree 2 files changed +13
-13
lines changed Original file line number Diff line number Diff line change 1919
2020namespace pten {
2121
22- template <typename T>
23- inline HOSTDEVICE T BernoulliFunctor (T p, T rand) {
24- PADDLE_ENFORCE_LE (p,
25- 1.0 ,
26- pten::errors::OutOfRange (
27- " The probability should be <= 1, but got %f" , p));
28- PADDLE_ENFORCE_GE (p,
29- 0.0 ,
30- pten::errors::OutOfRange (
31- " The probability should be >= 0, but got %f" , p));
32- return static_cast <T>(rand < p);
33- }
34-
3522template <typename T, typename Context>
3623void BernoulliKernel (const Context& ctx,
3724 const DenseTensor& x,
Original file line number Diff line number Diff line change 1919
2020namespace pten {
2121
22+ template <typename T>
23+ inline T BernoulliFunctor (T p, T rand) {
24+ PADDLE_ENFORCE_LE (p,
25+ 1.0 ,
26+ pten::errors::OutOfRange (
27+ " The probability should be <= 1, but got %f" , p));
28+ PADDLE_ENFORCE_GE (p,
29+ 0.0 ,
30+ pten::errors::OutOfRange (
31+ " The probability should be >= 0, but got %f" , p));
32+ return static_cast <T>(rand < p);
33+ }
34+
2235template <typename T, typename Context>
2336void BernoulliKernel (const Context& ctx,
2437 const DenseTensor& x,
You can’t perform that action at this time.
0 commit comments