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

Clean OpProtoAndCheckerMaker #10486

Merged
merged 4 commits into from
May 11, 2018

Conversation

reyoung
Copy link
Collaborator

@reyoung reyoung commented May 8, 2018

Do not use ctor

  • Reduce line of codes.
  • We can use virtual function for Maker now.
  • The implementation does not care what maker holds, it is easier to
    refactor later.

Do not use ctor

* Reduce line of codes.
* We can use virtual function for Maker now.
* The implementation does not care what maker holds, it is easier to
refactor later.

virtual ~OpProtoAndCheckerMaker() {
PADDLE_ENFORCE(validated_, "should call Validate after build");
CHECK(validated_) << "should call Validate after build";
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Exception in desturctor will only crash and cannot be catched. Change here to CHECK

}

void SetProto(proto::OpProto *proto) { proto_ = proto; }

void SetChecker(OpAttrChecker *attr_checker) { op_checker_ = attr_checker; }
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Do not use constructor to avoid all inherited classes to have a constructor.

Copy link
Contributor

@dzhwinter dzhwinter left a comment

Choose a reason for hiding this comment

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

This replacement looks great.

@reyoung reyoung merged commit 046405e into PaddlePaddle:develop May 11, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants