-
Notifications
You must be signed in to change notification settings - Fork 25
[Typing] Fix some typehint and add more assert #284
base: develop
Are you sure you want to change the base?
Conversation
@@ -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? |
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.
这里逻辑似乎有一些问题,我不确定是否应该改成self.ops.extend(sub_op),还是说ops应该是list[list[paddle.fluid.framework.Operator]]
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.
这里应该是 list[list[paddle.fluid.framework.Operator]]
,之前我没仔细看代码,加错了 😂,这段逻辑我最近需要稍微变动下,稍后的 PR 应该会一并改一下
except BreakGraphError as e: | ||
# TODO: backup_iter_idx is not None? |
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.
这里 backup_iter_idx == 0 的情况我感觉应该也进入分支,这样的话应该是if backup_iter_idx is not None。
# 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(), |
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.
这里TupleVariable传入的参数通常是list,但是实际上要求是tuple,这块是不是应该对TupleVariable修改一下改成iterable,感觉上应该没有什么影响。或者是这里套一个tuple
在 #258 的基础上,主要针对 opcode_executor.py 中的typehint进行优化,确保在绝大多数情况下,IDE的类型注解都可以正常工作。并对目前难以解决的情况添加了TODO。