Skip to content

add cpu random Generator #26013

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

Merged
merged 17 commits into from
Aug 18, 2020
Merged

Conversation

yaoxuefeng6
Copy link
Contributor

PR types

Others

PR changes

Others

Describe

bak

@paddle-bot-old
Copy link

paddle-bot-old bot commented Aug 6, 2020

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

@zhiqiu zhiqiu self-requested a review August 14, 2020 04:10
jzhang533
jzhang533 previously approved these changes Aug 14, 2020
Copy link
Contributor

@jzhang533 jzhang533 left a comment

Choose a reason for hiding this comment

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

lgtm
this is a breaking change, the related OP should remove ctx.Attr<int>("seed") accordingly.
@yaoxuefeng6 will have instructions on how to fix the related OP.
@XiaoguangHu01 , @willthefrog , please have a look.

} else {
unsigned int seed = static_cast<unsigned int>(ctx.Attr<int>("seed"));
std::minstd_rand engine;
if (seed == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what if use want to set seed to literal 0?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Currently It is not allowed in paddle, and related doc note this to users. If it is necessary to allow this, we can fix it.

namespace paddle {
namespace framework {

struct GeneratorState {
Copy link
Contributor

Choose a reason for hiding this comment

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

why note simply merge this into Generator as it is one-to-one "has a" relationship?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

To let State-related value be in this class. we can easily and clearly add things in this class later.

} else {
unsigned int seed = static_cast<unsigned int>(ctx.Attr<int>("seed"));
std::minstd_rand engine;
if (seed == 0) {
Copy link
Contributor

Choose a reason for hiding this comment

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

what if use want to set seed to literal 0?

Generator() {
GeneratorState default_gen_state_cpu;
default_gen_state_cpu.device = -1;
default_gen_state_cpu.current_seed = 34342423252;
Copy link
Contributor

Choose a reason for hiding this comment

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

default initialize with fixed seed?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

We should set a default one. maybe random?

Copy link
Contributor

@willthefrog willthefrog Aug 17, 2020

Choose a reason for hiding this comment

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

initialization with random seed seems more reasonable

@yaoxuefeng6 yaoxuefeng6 changed the title add Generator for bak add cpu random Generator Aug 18, 2020
Copy link
Contributor

@jzhang533 jzhang533 left a comment

Choose a reason for hiding this comment

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

lgtm
will merge and start testing

@yaoxuefeng6 yaoxuefeng6 requested a review from luotao1 August 18, 2020 04:20
Copy link
Contributor

@luotao1 luotao1 left a comment

Choose a reason for hiding this comment

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

LGTM for init.py

@yaoxuefeng6 yaoxuefeng6 merged commit 23261ff into PaddlePaddle:develop Aug 18, 2020
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.

4 participants