-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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
[Dy2Stat]Polish for zip in dy2stat #37846
Conversation
Thanks for your contribution! |
""" | ||
assert isinstance(node, gast.Call) | ||
if is_paddle_api(node): | ||
return True | ||
|
||
func_str = ast_to_source_code(node.func).strip() | ||
try: | ||
from paddle.fluid.dygraph.dygraph_to_static.convert_call_func import is_builtin_len, is_builtin | ||
from paddle.fluid.dygraph.dygraph_to_static.convert_call_func import is_builtin_len, is_builtin, is_builtin_zip |
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.
We should avoid Runtime import
, please put it ahead of the file.
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.
这里应该会有循环import的问题,放在前面会报错
def is_builtin_zip(func): | ||
if is_builtin(func) and func.__name__ == 'zip': | ||
return True | ||
return False |
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.
return is_builtin(func) and func.__name__ == 'zip'
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.
Done
if isinstance(arg, Variable) and arg.shape[0] == -1: | ||
raise ValueError( | ||
"If the parameter is Variable in 'zip', its first dimension should not be -1. " | ||
"But args[{}].shape[0] == -1 in 'zip'".format(str(i))) |
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.
"But args[{}].shape[0] == -1 in 'zip'".format(str(i))) | |
Not support zip(tensor, ...) when tensor.shape[0] == -1, but found args[{}].shape[0] == -1 in 'zip' |
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.
Done
def convert_zip(*args): | ||
for i, arg in enumerate(args): | ||
if isinstance(arg, Variable) and arg.shape[0] == -1: | ||
raise ValueError( |
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.
raise RuntimeError
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.
Done
* polish for zip in dy2stat * polish comment * polish is_builtin_len * fix comment
* polish for zip in dy2stat * polish comment * polish is_builtin_len * fix comment
PR types
Others
PR changes
Others
Describe
polish for zip in dy2stat