CARVIEW |
Navigation Menu
-
Notifications
You must be signed in to change notification settings - Fork 5.8k
[PIR] Refactor pir GetNameMap
and assert value
unique
#66738
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
[PIR] Refactor pir GetNameMap
and assert value
unique
#66738
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
@@ -495,6 +494,29 @@ inline void PirRunProgramAPI( | |||
details::print_collection(skip_names_set); | |||
interpreter_core->SetSkipGcVars(skip_names_set); | |||
|
|||
// check only one name |
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.
可以考虑:
- 在
GetNameFromValue
里加,这些 name 会直接用于 share 到 scope,所以这里能确保唯一不会有任何问题 unify_value_names
跑完后对所有 Value 重新检查一下,这里的 Program 之后也会直接传给RunProgramOp
,这里保证唯一也基本不会有啥问题
@@ -326,6 +326,8 @@ def program_attr(self): | |||
rename_mapping = RunnableProgram.unify_value_names( | |||
self.backward_program, rename_mapping | |||
) | |||
# check if every value has only one name. | |||
assert len(rename_mapping.values()) == len(set(rename_mapping.keys())) |
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.
?这是在干啥呢?
@@ -326,6 +326,8 @@ def program_attr(self): | |||
rename_mapping = RunnableProgram.unify_value_names( | |||
self.backward_program, rename_mapping | |||
) | |||
# check if every value has only one name. | |||
assert len(rename_mapping.values()) == len(set(rename_mapping.values())) |
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.
?这又是在干啥呢?
@@ -327,7 +327,8 @@ def program_attr(self): | |||
self.backward_program, rename_mapping | |||
) | |||
# check if every value has only one name. | |||
assert len(rename_mapping.values()) == len(set(rename_mapping.values())) | |||
for value in rename_mapping.values(): |
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.
会挂,有的 value 被删了,需要重新获取全部 values
@@ -39,6 +40,11 @@ std::vector<std::string> GetValueOutputNames(pir::Value value); | |||
pir::Value GetOutputValueByName(const pir::Program &program, | |||
const std::string &name); | |||
|
|||
inline bool IsOnlyOneValueName(pir::Value value) { |
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.
inline bool IsOnlyOneValueName(pir::Value value) { | |
inline bool HasOnlyOneValueName(pir::Value value) { |
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.
GetNameMap
and assert value
uniqueGetNameMap
and assert value
unique
// check only one name | ||
for (auto value : values) { | ||
PADDLE_ENFORCE(pir::utils::name_analysis::HasOnlyOneValueName(value), | ||
"Value should have only one name"); |
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.
2024-07-31 22:53:55 ****************
2024-07-31 22:53:55 0. The error message you wrote in PADDLE_ENFORCE{_**} or PADDLE_THROW does not meet our error message writing specification. Possible errors include 1. the error message is empty / 2. the error message is too short / 3. the error type is not specified. Please read the specification [ https://github.com/PaddlePaddle/Paddle/wiki/Paddle-Error-Message-Writing-Specification ], then refine the error message. If it is a mismatch, please request luotao1 or Aurelius84 review and approve.
2024-07-31 22:53:55 The PADDLE_ENFORCE{_**} or PADDLE_THROW entries that do not meet the specification are as follows:
2024-07-31 22:53:55 PADDLE_ENFORCE(pir::utils::name_analysis::HasOnlyOneValueName(value), + "Value should have only one name");
2024-07-31 22:53:55 There are 1 approved errors.
2024-07-31 22:53:55 ****************
需要声明具体类型,不能只写 message
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.
我加一下吧
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.
啊……我说的是二选一,你两个地方都加了啊……这里我直接删了
PR Category
Performance Optimization
PR Types
Not User Facing
Description
GetNameMap
相关链接: