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

fix attr bug in op_test and ensure order in duplicate inputs/outputs #4012

Merged
merged 3 commits into from
Sep 11, 2017

Conversation

QiJune
Copy link
Member

@QiJune QiJune commented Sep 11, 2017

Fix #4019

@QiJune QiJune requested review from qingqing01 and Xreki September 11, 2017 08:44
Xreki
Xreki previously approved these changes Sep 11, 2017
Copy link
Contributor

@Xreki Xreki left a comment

Choose a reason for hiding this comment

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

LGTM.
When the input is X: {X0, X1}, the current codes can not keep the order of X. This PR is to fix it. I have test this PR using my developing FCOp, which computes X0 * W0 + X1 * W1 + b.

@Yancey1989
Copy link
Contributor

Hi @Xreki @QiJune , the CI build failed, maybe we need to merge #4018 first, and pull the develop branch in this PR.

kwargs = dict()

for in_name, in_dup in Operator.get_op_inputs(op_type):
if in_name in inputs:
kwargs[in_name] = []
if in_dup:
sub_in = inputs[in_name]
for sub_in_name in sub_in:
for sub_in_name, arr in sub_in:
Copy link
Contributor

Choose a reason for hiding this comment

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

 for sub_in_name, _ in sub_in:

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

for sun_in_name in sub_in:
var = scope.new_var(sun_in_name)
kwargs[out_name].append(sun_in_name)
for sub_in_name, arr in sub_in:
Copy link
Contributor

Choose a reason for hiding this comment

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

for sub_in_name, _ in sub_in:

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -46,10 +47,9 @@ def set_input(scope, op, inputs, place):
if in_name in inputs:
if in_dup:
sub_in = inputs[in_name]
for sub_in_name in sub_in:
for sub_in_name, arr in sub_in:
Copy link
Contributor

Choose a reason for hiding this comment

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

Make name more clear.

 for sub_in_name, sub_array in sub_in:

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

@@ -168,7 +168,11 @@ def get_gradient(scope, op, inputs, outputs, grad_name, place,
class OpTest(unittest.TestCase):
def check_output_with_place(self, place):
self.scope = core.Scope()
self.op = create_op(self.scope, self.op_type, self.inputs, self.outputs)
op_inputs = self.inputs if hasattr(self, "inputs") else dict()
op_outputs = self.outputs if hasattr(self, "outputs") else dict()
Copy link
Contributor

Choose a reason for hiding this comment

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

When the users could not set self.inputs and self.outputs ? Aren't they always needed?

Copy link
Member Author

Choose a reason for hiding this comment

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

Some operator, like random operator has no input. NOP has no input and output.
I will remove self.outputs here.

@typhoonzero
Copy link
Contributor

Need to add "Fix [issue url]" in the PR description.

@QiJune QiJune merged commit f2156e4 into PaddlePaddle:develop Sep 11, 2017
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.

5 participants