Skip to content
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

Merged
merged 1 commit into from
Aug 4, 2023
Merged

Conversation

co63oc
Copy link
Contributor

@co63oc co63oc commented Jul 21, 2023

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

不支持API
380 torch.onnx.enable_log
381 torch.onnx.disable_log

paddle onnx下为export,没有enable_log, disable_log

396 torch.nn.Module.to_empty 
398 torch.nn.Module.register_full_backward_pre_hook 
399 torch.nn.Module.register_full_backward_hook 
400 torch.nn.Module.requires_grad_ 

因为torch.nn.Module 在转换框架中识别为torch.Tensor类型,以下API使用def _test定义没有启用
391 torch.nn.Module.type
392 torch.nn.Module.float
393 torch.nn.Module.double
394 torch.nn.Module.half
395 torch.nn.Module.bfloat16

397 torch.nn.Module.to

401 torch.nn.Module.zero_grad

@paddle-bot
Copy link

paddle-bot bot commented Jul 21, 2023

Thanks for your contribution!

@paddle-bot paddle-bot bot added contributor External developers status: proposed labels Jul 21, 2023
@luotao1 luotao1 added the HappyOpenSource 快乐开源活动issue与PR label Jul 21, 2023
@co63oc co63oc force-pushed the api380 branch 2 times, most recently from eddc085 to b4a8b4c Compare July 21, 2023 21:55
@co63oc co63oc changed the title 转换规则 No. 380/381/396/398/399/400 转换规则 No. 380/381/391-401 Jul 21, 2023
@@ -3634,6 +3634,23 @@ def generate_code(self, kwargs):
)


class NnModuleTypeMatcher(BaseMatcher):
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个看起来没有用到

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已删除

@@ -6673,7 +6673,10 @@
"torch.nn.Module.apply": {
"Matcher": "TensorUnchangeMatcher"
},
"torch.nn.Module.bfloat16": {},
"torch.nn.Module.bfloat16": {
Copy link
Collaborator

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 来

Copy link
Contributor Author

@co63oc co63oc Jul 25, 2023

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

@@ -6690,16 +6693,25 @@
},
"torch.nn.Module.cpu": {},
"torch.nn.Module.cuda": {},
"torch.nn.Module.double": {},
"torch.nn.Module.double": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

先不支持

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已删除

"torch.nn.Module.eval": {
"Matcher": "TensorUnchangeMatcher"
},
"torch.nn.Module.float": {},
"torch.nn.Module.float": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

先不支持

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已删除

"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": {
Copy link
Collaborator

Choose a reason for hiding this comment

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

先不支持

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已删除

module1 = torch.nn.Module()
module1.register_buffer('buffer', x)
module1.zero_grad()
result = module1.buffer
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个是不是得测梯度?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已修改

@co63oc co63oc force-pushed the api380 branch 2 times, most recently from af61cbb to 111928e Compare July 25, 2023 03:04
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
Copy link
Collaborator

Choose a reason for hiding this comment

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

这里不能注释,不然单测就失效了

Copy link
Contributor Author

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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

这个API应该paddle也有,可以直接unchangematcher

Copy link
Collaborator

Choose a reason for hiding this comment

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

如果无法通过unsupport=True来跑,就使用 def _test 吧,但不能修改基类

Copy link
Contributor Author

@co63oc co63oc Aug 1, 2023

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

Copy link
Contributor Author

@co63oc co63oc Aug 1, 2023

Choose a reason for hiding this comment

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

会显示覆盖率不足问题
图片

Copy link
Collaborator

@zhwesky2010 zhwesky2010 left a comment

Choose a reason for hiding this comment

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

LGTM

@luotao1
Copy link
Collaborator

luotao1 commented Aug 4, 2023

请重新触发下CI来通过 PR-CI-InstallCheck

@co63oc
Copy link
Contributor Author

co63oc commented Aug 4, 2023

请重新触发下CI来通过 PR-CI-InstallCheck

已触发

@luotao1 luotao1 merged commit e286d28 into PaddlePaddle:master Aug 4, 2023
@co63oc co63oc deleted the api380 branch August 19, 2023 00:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers HappyOpenSource 快乐开源活动issue与PR status: proposed
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants