-
Notifications
You must be signed in to change notification settings - Fork 55
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. 380/381/391-401 #186
Conversation
Thanks for your contribution! |
eddc085
to
b4a8b4c
Compare
paconvert/api_matcher.py
Outdated
@@ -3634,6 +3634,23 @@ def generate_code(self, kwargs): | |||
) | |||
|
|||
|
|||
class NnModuleTypeMatcher(BaseMatcher): |
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.
已删除
paconvert/api_mapping.json
Outdated
@@ -6673,7 +6673,10 @@ | |||
"torch.nn.Module.apply": { | |||
"Matcher": "TensorUnchangeMatcher" | |||
}, | |||
"torch.nn.Module.bfloat16": {}, | |||
"torch.nn.Module.bfloat16": { |
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.Module.*
中这些与 torch.Tensor.*
同名的API就先不支持吧,机制识别上还有点问题,但是单测可以都先写了,按设置 unsupport=True 来
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.
已修改
因为设置后测试还是按Tensor转换,代码中没有“>>>”标识,所以修改apibase.py,注释.assert ">>>"行
因为 type使用Tensor Matcher转换检查参数dtype错误,修改API名称为 type_unsupport
paconvert/api_mapping.json
Outdated
@@ -6690,16 +6693,25 @@ | |||
}, | |||
"torch.nn.Module.cpu": {}, | |||
"torch.nn.Module.cuda": {}, | |||
"torch.nn.Module.double": {}, | |||
"torch.nn.Module.double": { |
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.
已删除
paconvert/api_mapping.json
Outdated
"torch.nn.Module.eval": { | ||
"Matcher": "TensorUnchangeMatcher" | ||
}, | ||
"torch.nn.Module.float": {}, | ||
"torch.nn.Module.float": { |
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.
已删除
paconvert/api_mapping.json
Outdated
"torch.nn.Module.get_buffer": {}, | ||
"torch.nn.Module.get_extra_state": {}, | ||
"torch.nn.Module.get_parameter": {}, | ||
"torch.nn.Module.get_submodule": {}, | ||
"torch.nn.Module.half": {}, | ||
"torch.nn.Module.half": { |
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.
已删除
tests/test_nn_Module_zero_grad.py
Outdated
module1 = torch.nn.Module() | ||
module1.register_buffer('buffer', x) | ||
module1.zero_grad() | ||
result = module1.buffer |
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.
已修改
af61cbb
to
111928e
Compare
tests/apibase.py
Outdated
@@ -60,7 +60,7 @@ def run( | |||
reason is not None | |||
), "Please explain the reason why it is not supported" | |||
paddle_code = self.convert(pytorch_code) | |||
assert ">>>" in paddle_code |
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.
已还原
x = torch.tensor([1., 2., 3.]) | ||
module1 = torch.nn.Module() | ||
module1.register_buffer('buffer', x) | ||
module1.to(device="cpu", non_blocking=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.
这个API应该paddle也有,可以直接unchangematcher
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.
如果无法通过unsupport=True来跑,就使用 def _test
吧,但不能修改基类
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.
是系统会使用Tensor的规则匹配,不是nn.Module配置
已修改使用def _test
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
请重新触发下CI来通过 PR-CI-InstallCheck |
已触发 |
PR Docs
#112
映射文档
380 torch.onnx.enable_log PaddlePaddle/docs#6017
381 torch.onnx.disable_log PaddlePaddle/docs#6017
paddle onnx下为export,没有enable_log, disable_log
396 torch.nn.Module.to_empty PaddlePaddle/docs#6009
398 torch.nn.Module.register_full_backward_pre_hook PaddlePaddle/docs#6009
399 torch.nn.Module.register_full_backward_hook PaddlePaddle/docs#6009
400 torch.nn.Module.requires_grad_ PaddlePaddle/docs#6009
因为torch.nn.Module 在转换框架中识别为torch.Tensor类型,以下API使用def _test定义没有启用
391 torch.nn.Module.type PaddlePaddle/docs#6009
392 torch.nn.Module.float PaddlePaddle/docs#6009
393 torch.nn.Module.double PaddlePaddle/docs#6009
394 torch.nn.Module.half PaddlePaddle/docs#6009
395 torch.nn.Module.bfloat16 PaddlePaddle/docs#6009
397 torch.nn.Module.to PaddlePaddle/docs#6009
401 torch.nn.Module.zero_grad PaddlePaddle/docs#6009
PR APIs