Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add dirichlet random sample op in cpu and gpu kernel #38244

Merged
merged 5 commits into from
Dec 30, 2021

Conversation

cxxly
Copy link
Contributor

@cxxly cxxly commented Dec 17, 2021

PR types

New features

PR changes

OPs

Describe

Dirichlet and Beta distribution API need fast dirichlet random generator for draw sample data, we implement it in cpu and cuda backend use reject-accept sample and inverse-transform sample method.

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@cxxly cxxly changed the title add dirichlet random sample op in cuda and cpu kernel add dirichlet random sample op in CPU and GPU kernel Dec 24, 2021
@cxxly cxxly changed the title add dirichlet random sample op in CPU and GPU kernel add dirichlet random sample op in cpu and gpu kernel Dec 24, 2021
Comment on lines 23 to 41
#define compat_exp exp
#define compat_ceil ceil
#define compat_floor floor
#define compat_log log
#define compat_pow pow
#define compat_sqrt sqrt
#define compat_tan tan
#define compat_abs abs
#define compat_log1p log1p
#else
#define compat_exp std::exp
#define compat_ceil std::ceil
#define compat_floor std::floor
#define compat_log std::log
#define compat_pow std::pow
#define compat_sqrt std::sqrt
#define compat_tan std::tan
#define compat_abs std::abs
#define compat_log1p std::log1p
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macro's name use underline delimited all capital charactor nomenclature

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

updated

template <typename DeviceContext, typename T>
struct DirichletSampler;

template <typename scalar_t, typename sampler_t>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first letter of template parameter should be capitalized.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have updated

Comment on lines 31 to 38
#define compat_rand_init curand_init
#define compat_rand_uniform curand_uniform
#define compat_rand_normal curand_normal
#elif defined(PADDLE_WITH_HIP)
using compatRandStatePhilox4_32_10_t = hiprandStatePhilox4_32_10_t;
#define compat_rand_init hiprand_init
#define compat_rand_uniform hiprand_uniform
#define compat_rand_normal hiprand_normal
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

macro's name use underline delimited all capital charactor nomenclature

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have updated

Comment on lines 81 to 82
template <typename scalar_t, typename accscalar_t, typename uniform_sampler_t,
typename normal_sampler_t>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first letter of template parameter should be capitalized.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have updated


namespace paddle {
namespace operators {
template <typename T, typename uniform_sampler_t, typename normal_sampler_t>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The first letter of template parameter should be capitalized.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

have updated

Copy link
Contributor

@jeff41404 jeff41404 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@iclementine iclementine merged commit c5bf09b into PaddlePaddle:develop Dec 30, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants