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.388/389/390 #155

Merged
merged 2 commits into from
Jul 18, 2023
Merged

Conversation

co63oc
Copy link
Contributor

@co63oc co63oc commented Jul 5, 2023

PR Docs

#112

已取消 修改 paconvert/transformer/basic_transformer.py,增加test_api变量,传入需要测试的api名称,按api名称判断匹配顺序 torch.nn.Module, torch.Tensor,比如cpu类型,原来是拼接为 torch.Tensor.cpu 匹配,这样使用的Matcher不对,需要匹配torch.nn.Module.cpu

xpu类型CI不能测试,修改为_def test

PR APIs

torch.nn.Module.cuda
torch.nn.Module.xpu
torch.nn.Module.cpu

[used AI Studio]

@paddle-bot
Copy link

paddle-bot bot commented Jul 5, 2023

Thanks for your contribution!

result = ">>>"
"""
)
obj.run(
Copy link
Collaborator

Choose a reason for hiding this comment

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

CPU为什么不支持呢,paddle也有.cpu用法

Copy link
Contributor Author

Choose a reason for hiding this comment

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

图片

搜索文档没有找到cpu使用,那麻烦发下关联文档

Copy link
Collaborator

@zhwesky2010 zhwesky2010 Jul 7, 2023

Choose a reason for hiding this comment

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

可以直接跑代码,最终均以代码为准

这个文档在paddle.Tensor里:https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/Tensor_cn.html#cpu

Copy link
Contributor Author

Choose a reason for hiding this comment

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

paddle修改的是Tensor,Pytorch修改的是Module,没有找到Module和Tensor的转换文档

图片
图片

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

Choose a reason for hiding this comment

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

cuda为什么不支持呢,paddle也有这个功能,result=">>>"这个就不要写了,用户代码不可能有这个

Copy link
Contributor Author

Choose a reason for hiding this comment

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

图片
搜索没有cuda使用,那麻烦发下关联文档

@zhwesky2010
Copy link
Collaborator

另外只需要处理issue里408个任务的API,其他的API在发布任务都已经做了筛选分析或者实现。

@co63oc
Copy link
Contributor Author

co63oc commented Jul 7, 2023

另外只需要处理issue里408个任务的API,其他的API在发布任务都已经做了筛选分析或者实现。

好的

zhwesky2010
zhwesky2010 previously approved these changes Jul 7, 2023
@zhwesky2010
Copy link
Collaborator

另外只需要处理issue里408个任务的API,其他的API在发布任务都已经做了筛选分析或者实现。

好的

上面看错了看成是torch.Tensor.cpu,这个确实API缺失,你先改成 def _test 这种无法运行的形式吧

@luotao1
Copy link
Collaborator

luotao1 commented Jul 7, 2023

如果api缺失,也需要文档,在pytorch_api_mapping里写下功能缺失。单测需要开发 不运行的注释版本。

@co63oc
Copy link
Contributor Author

co63oc commented Jul 7, 2023

上面看错了看成是torch.Tensor.cpu,这个确实API缺失,你先改成 def _test 这种无法运行的形式吧

已找到匹配api https://www.paddlepaddle.org.cn/documentation/docs/zh/api/paddle/nn/Layer_cn.html#to-device-none-dtype-none-blocking-none
图片

已修改 xpu 为 def _test ,转换cpu, cuda
修改 paconvert/transformer/basic_transformer.py,修改匹配顺序 torch.nn.Module, torch.Tensor,比如cpu类型,原来是先匹配torch.Tensor.cpu,这样使用的Matcher不对

@co63oc
Copy link
Contributor Author

co63oc commented Jul 7, 2023

如果api缺失,也需要文档,在pytorch_api_mapping里写下功能缺失。单测需要开发 不运行的注释版本。

好的那再创建PR

@co63oc co63oc closed this Jul 10, 2023
@co63oc co63oc reopened this Jul 10, 2023
@PaddlePaddle PaddlePaddle locked and limited conversation to collaborators Jul 11, 2023
@PaddlePaddle PaddlePaddle unlocked this conversation Jul 11, 2023
tests/apibase.py Outdated
@@ -174,6 +174,7 @@ def convert(self, pytorch_code):
f.write(pytorch_code)

converter = Converter(log_dir="disable")
converter.set_test_api(self.pytorch_api)
Copy link
Collaborator

@zhwesky2010 zhwesky2010 Jul 11, 2023

Choose a reason for hiding this comment

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

这个可能没法像这样判断,因为单测里只有一种类型pytorch_api,但是在实际代码里是混合的,只为跑通单测意义不大,单测的价值就是模仿用户代码。

这3个API先按功能缺失来吧,后面会新增cpu、gpu、xpu三个api,这样也就不存在Module和Tensor的差异了

Copy link
Contributor Author

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.

使用def _test CI显示覆盖率错误
图片

@co63oc
Copy link
Contributor Author

co63oc commented Jul 16, 2023

使用 def _test方式显示覆盖率不足

图片

@zhwesky2010
Copy link
Collaborator

使用 def _test方式显示覆盖率不足

图片

覆盖率我豁免了,另外文档合入了吧

@zhwesky2010 zhwesky2010 merged commit b3dca06 into PaddlePaddle:master Jul 18, 2023
@co63oc co63oc deleted the doc0705 branch August 4, 2023 13:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants