-
Notifications
You must be signed in to change notification settings - Fork 5.9k
[PIR][Dy2St] Adapt opcallstack for D2S #62536
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
Merged
SigureMo
merged 10 commits into
PaddlePaddle:develop
from
xingmingyyj:adaptive_opcallstack
Mar 12, 2024
Merged
Changes from 2 commits
Commits
Show all changes
10 commits
Select commit
Hold shift + click to select a range
5235ceb
opcallstack adptive d2s
xingmingyyj 0c8af2a
opcallstack adptive d2s
xingmingyyj cb24e9a
fix
xingmingyyj 4b2bc9e
add PIR only test `test_error`
SigureMo 70b06e2
use PADDLE_GET_CONST and update approval
SigureMo c8f932c
`error_type` -> `invalid_type`
SigureMo 787e1e4
remove tab in test_legacy_error
SigureMo 02370d0
Merge branch 'develop' into adaptive_opcallstack
SigureMo 5840971
Merge branch 'develop' into adaptive_opcallstack
SigureMo e8bd744
Merge branch 'develop' into adaptive_opcallstack
SigureMo File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -16,7 +16,7 @@ | |||||
| from collections.abc import Sequence | ||||||
|
|
||||||
| from paddle.base import core | ||||||
| from paddle.base.framework import Program | ||||||
| from paddle.framework import use_pir_api | ||||||
| from paddle.utils import gast | ||||||
|
|
||||||
| from .utils import ORIGIN_INFO | ||||||
|
|
@@ -269,8 +269,6 @@ def update_op_callstack_with_origin_info(program): | |||||
| Replaces op callstack information about transformed static code with original dygraph code. | ||||||
| """ | ||||||
|
|
||||||
| assert isinstance(program, Program) | ||||||
xingmingyyj marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
|
|
||||||
| def get_new_op_callstack(callstack): | ||||||
| """ | ||||||
| An example of callstack: | ||||||
|
|
@@ -306,21 +304,36 @@ def get_new_op_callstack(callstack): | |||||
|
|
||||||
| return callstack | ||||||
|
|
||||||
| def get_all_pir_block_ops(block, ops): | ||||||
| for op in block.ops: | ||||||
| ops.append(op) | ||||||
| for sub_block in op.blocks(): | ||||||
| get_all_pir_block_ops(sub_block, ops) | ||||||
xingmingyyj marked this conversation as resolved.
Outdated
Show resolved
Hide resolved
|
||||||
|
|
||||||
| op_maker = core.op_proto_and_checker_maker | ||||||
| callstack_var_name = op_maker.kOpCreationCallstackAttrName() | ||||||
|
|
||||||
| for block in program.blocks: | ||||||
| for i, op in enumerate(block.ops): | ||||||
| if use_pir_api(): | ||||||
| global_block = program.global_block() | ||||||
| ops = [] | ||||||
| get_all_pir_block_ops(global_block, ops) | ||||||
| for op in ops: | ||||||
| if op.has_attr(callstack_var_name): | ||||||
| callstack = op.attr(callstack_var_name) | ||||||
|
|
||||||
| callstack = op.attrs()[callstack_var_name] | ||||||
| callstack = get_new_op_callstack(callstack) | ||||||
|
|
||||||
| try: | ||||||
| # (@xiongkun) In 2-order derivative for paddle science, there may exists `pow_grad` | ||||||
| # which has op_proto == nullptr and causes _set_attr failed. so we add a try...except. | ||||||
| op._set_attr(callstack_var_name, callstack) | ||||||
| except: | ||||||
| pass | ||||||
|
|
||||||
| op.set_opcallstack(callstack) | ||||||
| else: | ||||||
| for block in program.blocks: | ||||||
| for i, op in enumerate(block.ops): | ||||||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
可以不需要使用
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 老代码加缩进而已,反正这个分支以后也会删 |
||||||
| if op.has_attr(callstack_var_name): | ||||||
| callstack = op.attr(callstack_var_name) | ||||||
|
|
||||||
| callstack = get_new_op_callstack(callstack) | ||||||
|
|
||||||
| try: | ||||||
| # (@xiongkun) In 2-order derivative for paddle science, there may exists `pow_grad` | ||||||
| # which has op_proto == nullptr and causes _set_attr failed. so we add a try...except. | ||||||
| op._set_attr(callstack_var_name, callstack) | ||||||
| except: | ||||||
| pass | ||||||
| return program | ||||||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.