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

[SOT][3.12] extract RETURN_VALUE and RETURN_CONST hard code #62073

Merged

Conversation

diadestiny
Copy link
Contributor

@diadestiny diadestiny commented Feb 26, 2024

PR types

Others

PR changes

Others

Description

extract RETURN_VALUE and RETURN_CONST hard code

Copy link

paddle-bot bot commented Feb 26, 2024

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Feb 26, 2024
gouzil
gouzil previously approved these changes Feb 26, 2024
@@ -1751,7 +1753,7 @@ def _break_graph_when_if(self, result: TensorVariable, instr: Instruction):

# 2. create true_fn and false_fn
def create_if_branch_fn(start_idx, input_var_names):
if self._instructions[start_idx].opname == "RETURN_VALUE":
if self._instructions[start_idx].opname in RETURN:
Copy link
Member

Choose a reason for hiding this comment

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

这里之前是不是考虑过,如果包含 "RETURN_CONST" 是不对的?

Copy link
Member

Choose a reason for hiding this comment

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

这个文件下面两处应该有同样的问题~

Copy link
Contributor Author

Choose a reason for hiding this comment

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

这个地方,我试了一下如果走到 if x_tensor>0: return 1 确实会触发assert true_fn is not None 出错;原因应该是如果是3.12以前返回const的字节码是LOAD_CONSTRETURN_VALUE,所以这里应该不能返回NULL;3.12字节码变成只有RETURN_CONST,所以包含"RETURN_CONST"会返回NULL确实不对。

后两处应该也是同样原因,虽然没想到会报错的例子,那我这三处都改回来,保持对齐以前的逻辑

@@ -1751,7 +1753,7 @@ def _break_graph_when_if(self, result: TensorVariable, instr: Instruction):

# 2. create true_fn and false_fn
def create_if_branch_fn(start_idx, input_var_names):
if self._instructions[start_idx].opname == "RETURN_VALUE":
if self._instructions[start_idx].opname == "RETURE_VALUE":
Copy link
Member

Choose a reason for hiding this comment

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

拼写错了哦

@@ -26,6 +26,7 @@
HAS_FREE = {opcode.opname[x] for x in opcode.hasfree}
ALL_JUMP = REL_JUMP | ABS_JUMP
UNCONDITIONAL_JUMP = {"JUMP_ABSOLUTE", "JUMP_FORWARD"}
RETURN = {"RETURN_VALUE", "RETURN_CONST"}
Copy link
Member

Choose a reason for hiding this comment

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

这里不要把 UNCONDITIONAL_JUMP 给分离开呀

另外这里的 RETURN 也可以和 UNCONDITIONAL_JUMP 处理方式一样 3.12 才 add RETURN_CONST

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
Member

@SigureMo SigureMo left a comment

Choose a reason for hiding this comment

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

LGTMeow

@SigureMo SigureMo changed the title [SOT][3.12] extract RETURN_VALUE and RETURN_CONST hard code [SOT][3.12] extract RETURN_VALUE and RETURN_CONST hard code Feb 27, 2024
@SigureMo SigureMo merged commit 7a97c10 into PaddlePaddle:develop Feb 27, 2024
30 checks passed
@diadestiny diadestiny deleted the extract_RETURN_VALUE_and_CONST branch February 27, 2024 04:26
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants