Skip to content
This repository has been archived by the owner on Jan 24, 2024. It is now read-only.

[Typing] Fix some typehint and add more assert #284

Open
wants to merge 7 commits into
base: develop
Choose a base branch
from

Conversation

zrr1999
Copy link
Member

@zrr1999 zrr1999 commented Jul 23, 2023

#258 的基础上,主要针对 opcode_executor.py 中的typehint进行优化,确保在绝大多数情况下,IDE的类型注解都可以正常工作。并对目前难以解决的情况添加了TODO。

@@ -255,6 +255,7 @@ def add_subgraph(self, program: Program):
for op in block.ops:
self.op_num += 1
sub_op.append(op)
# TODO: self.ops is a list, and sub_op is a list?
Copy link
Member Author

Choose a reason for hiding this comment

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

这里逻辑似乎有一些问题,我不确定是否应该改成self.ops.extend(sub_op),还是说ops应该是list[list[paddle.fluid.framework.Operator]]

Copy link
Member

Choose a reason for hiding this comment

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

这里应该是 list[list[paddle.fluid.framework.Operator]],之前我没仔细看代码,加错了 😂,这段逻辑我最近需要稍微变动下,稍后的 PR 应该会一并改一下

except BreakGraphError as e:
# TODO: backup_iter_idx is not None?
Copy link
Member Author

Choose a reason for hiding this comment

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

这里 backup_iter_idx == 0 的情况我感觉应该也进入分支,这样的话应该是if backup_iter_idx is not None。

Comment on lines +1433 to 1439
# TODO(zrr1999): I think list_value should a ListVariable instance,
# but return_value of get_wrapped_items method in ListVariable is a list instead of tuple.
# list_value = self.pop(var_type=ListVariable)
list_value = self.pop(var_type=ContainerVariable)
self.push(
TupleVariable(
list_value.get_wrapped_items(),
Copy link
Member Author

Choose a reason for hiding this comment

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

这里TupleVariable传入的参数通常是list,但是实际上要求是tuple,这块是不是应该对TupleVariable修改一下改成iterable,感觉上应该没有什么影响。或者是这里套一个tuple

@paddle-bot paddle-bot bot added the contributor External developers label Jul 23, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants