-
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
[Prim]fix attrs loss in creating op #50780
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.
some comments
if self._has_kernel(type): | ||
self.desc.infer_var_type(self.block.desc) | ||
self.desc.infer_shape(self.block.desc) | ||
|
||
def _has_kernel(self, op_type): | ||
return op_type not in self.OP_WITHOUT_KERNEL_SET | ||
|
||
def _get_runtime_attrs(self): |
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.
Add comments to avoid other one using this.
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
@@ -656,8 +656,10 @@ def expand_nested_list(xs): | |||
outputs[op.output_names[i]] = op.output(op.output_names[i]) | |||
|
|||
attrs = {} | |||
for name in sorted(op.attr_names): | |||
attrs[name] = op.attr(name) | |||
runtime_attrs = op._get_runtime_attrs() |
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.
Add comments to explain why we need this.
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
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
PR types
Bug fixes
PR changes
Others
Describe
When setting composite forward ops, during creating operator, there may be some attrs loss which should be added.
For example, after constructing program of op dropout, attrs seed and fix_seed will not appear in program. In this case, when we need to copy the same op from origin program, attrs seed and fix_seed cannot be got by op.attr_names. So we use special member property defined during origin op initialization.