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

[Prim]fix attrs loss in creating op #50780

Merged
merged 5 commits into from
Feb 24, 2023

Conversation

cyber-pioneer
Copy link
Contributor

@cyber-pioneer cyber-pioneer commented Feb 22, 2023

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.

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

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):
Copy link
Contributor

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.

Copy link
Contributor Author

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()
Copy link
Contributor

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.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

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

LGTM

@JiabinYang JiabinYang merged commit 016f5ec into PaddlePaddle:develop Feb 24, 2023
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.

3 participants