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

[Eager] Support EagerTensor initialization with kwargs #38488

Merged

Conversation

veyron95
Copy link
Contributor

PR types

New features

PR changes

APIs

Describe

  1. Support EagerTensor initialization with kwargs.
  2. Add necessary unit tests to ensure the robustness of new constructor.

@paddle-bot-old
Copy link

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

Copy link
Contributor

@JiabinYang JiabinYang left a comment

Choose a reason for hiding this comment

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

some comments

paddle/fluid/pybind/eager.cc Outdated Show resolved Hide resolved
paddle/fluid/pybind/eager.cc Show resolved Hide resolved
paddle/fluid/pybind/eager.cc Show resolved Hide resolved
paddle/fluid/pybind/eager.cc Show resolved Hide resolved
paddle/fluid/pybind/eager.cc Outdated Show resolved Hide resolved
paddle/fluid/pybind/eager.cc Outdated Show resolved Hide resolved
paddle/fluid/pybind/eager.cc Outdated Show resolved Hide resolved
paddle/fluid/pybind/eager.cc Outdated Show resolved Hide resolved
self.assertTrue(egr_tensor24.place._equals(place))
self.assertTrue(np.array_equal(egr_tensor24.numpy(), x))

def test_constructor_with_kwargs(self):
Copy link
Contributor

@JiabinYang JiabinYang Dec 30, 2021

Choose a reason for hiding this comment

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

Miss some case like kwargs first and then args

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is a case of a syntax error:kwargs first and then args case,
SyntaxError: positional argument follows keyword argument.

Copy link
Contributor

Choose a reason for hiding this comment

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

Test this error maybe

Copy link
Contributor Author

Choose a reason for hiding this comment

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

SyntaxError could not be catch, maybe hard to test.

JiabinYang
JiabinYang previously approved these changes Jan 4, 2022
Copy link
Contributor

@JiabinYang JiabinYang left a comment

Choose a reason for hiding this comment

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

LGTM

self.assertTrue(egr_tensor24.place._equals(place))
self.assertTrue(np.array_equal(egr_tensor24.numpy(), x))

def test_constructor_with_kwargs(self):
Copy link
Contributor

Choose a reason for hiding this comment

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

Test this error maybe

Copy link
Contributor

@JiabinYang JiabinYang left a comment

Choose a reason for hiding this comment

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

LGTM

@veyron95 veyron95 merged commit 4ba6d4e into PaddlePaddle:develop Jan 5, 2022
@veyron95 veyron95 changed the title Support EagerTensor initialization with kwargs [Eager] Support EagerTensor initialization with kwargs Jan 25, 2022
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.

2 participants