-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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
Conversation
There was a problem hiding this 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
.
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: |
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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: |
There was a problem hiding this comment.
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:
There was a problem hiding this comment.
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() |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
Need to add "Fix [issue url]" in the PR description. |
Fix #4019