-
Notifications
You must be signed in to change notification settings - Fork 53
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
转换规则 No.384-387 #245
转换规则 No.384-387 #245
Conversation
paconvert/api_matcher.py
Outdated
@@ -3942,6 +3942,15 @@ def generate_code(self, kwargs): | |||
return code | |||
|
|||
|
|||
class ModuleGetSubMatcher(BaseMatcher): | |||
def generate_code(self, kwargs): | |||
code = "{}.{}".format( |
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.
getattr({}, {})
来实现吧,因为target可能是一个字符串变量,可能会出错
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.
已修改
x = torch.tensor([1., 2., 3.]) | ||
module1 = torch.nn.Module() | ||
module1.register_parameter('param1', torch.nn.parameter.Parameter(x)) | ||
result = module2.get_parameter('param1') |
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.
用torch.nn.Linear(10, 10).weight
这种形式返回一个Parameter吧
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.
查看已有torch.nn.parameter.Parameter,已修改
import torch | ||
x = torch.tensor([1., 2., 3.]) | ||
module1 = torch.nn.Module() | ||
module1.register_parameter('param1', torch.nn.parameter.Parameter(x)) |
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.
用torch.nn.Linear(10, 10).weight
这种形式返回一个Parameter吧
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.
查看已有torch.nn.parameter.Parameter,已修改
paconvert/api_mapping.json
Outdated
"args_list": [ | ||
"target" | ||
] | ||
}, | ||
"torch.nn.Module.get_extra_state": {}, | ||
"torch.nn.Module.get_parameter": {}, |
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.
get_parameter、register_parameter还没有实现
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.
已修改
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.
LGTM
PR Docs
#112
映射文档 PaddlePaddle/docs#6119
384 torch.nn.Module.register_parameter 因为调用 torch.nn.parameter.Parameter 不能转换,测试用例设置为unsupport
385 torch.nn.Module.get_submodule 替换为属性
386 torch.nn.Module.get_parameter 替换为属性, 因为调用 torch.nn.parameter.Parameter 不能转换,测试用例设置为unsupport
387 torch.nn.Module.get_buffer 替换为属性
PR APIs