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

【Hackathon 5th No.44】API转换 42-61 -part #324

Merged
merged 5 commits into from
Nov 16, 2023

Conversation

co63oc
Copy link
Collaborator

@co63oc co63oc commented Nov 5, 2023

PR Docs

https://github.com/PaddlePaddle/community/blob/master/hackathon/hackathon_5th/%E3%80%90PaddlePaddle%20Hackathon%205th%E3%80%91%E5%BC%80%E6%BA%90%E8%B4%A1%E7%8C%AE%E4%B8%AA%E4%BA%BA%E6%8C%91%E6%88%98%E8%B5%9B%E6%A1%86%E6%9E%B6%E5%BC%80%E5%8F%91%E4%BB%BB%E5%8A%A1%E5%90%88%E9%9B%86.md#no46%E4%B8%BApaddle%E4%BB%A3%E7%A0%81%E8%BD%AC%E6%8D%A2%E5%B7%A5%E5%85%B7%E6%96%B0%E5%A2%9Eapi%E8%BD%AC%E6%8D%A2%E8%A7%84%E5%88%99
API转换名单 中第5组(编号为84 ~ 102)

文档 PR PaddlePaddle/docs#6288

PR APIs

42	torch.linalg.eigh	paddle.linalg.eigh	返回第二个值参数符号不同,不确定是否是功能缺失
43	torch.linalg.eigvalsh	paddle.linalg.eigvalsh	已有文档验证无误
44	torch.linalg.pinv	paddle.linalg.pinv	修改文档参数
45	torch.linalg.svd	paddle.linalg.svd	返回值只有S相同,U,V部分值符号不同,不确定是否分类功能缺失
46	torch.linalg.solve	paddle.linalg.solve	已有文档验证无误
47	torch.linalg.eig	paddle.linalg.eig	修改文档参数
48	torch.Tensor.float_power		增加文档,组合替代实现
49	torch.Tensor.float_power_		增加文档,组合替代实现
50	torch.Tensor.lstsq	paddle.Tensor.lstsq	功能缺失,文档已说明返回值不同,原修改PR  https://github.com/PaddlePaddle/PaConvert/pull/219
51	torch.pca_lowrank	paddle.linalg.pca_lowrank	已有文档验证无误
52	torch.symeig	paddle.linalg.eigh	python1.9以上版本不支持,修改文档内容,如果替换为eigh,返回值第二个参数符号不同
53	torch.Tensor.symeig	paddle.linalg.eigh	python1.9以上版本不支持,修改文档内容,如果替换为eigh,返回值第二个参数符号不同
54	torch.linalg.inv_ex	paddle.linalg.inv	功能缺失,pytorch 返回info字段,paddle不支持
55	torch.linalg.matrix_norm	paddle.linalg.norm	增加文档
56	torch.linalg.vector_norm	paddle.linalg.norm	增加文档
57	torch.linalg.cholesky_ex	paddle.linalg.cholesky	功能缺失,pytorch 返回info字段,paddle不支持
58	torch.Tensor.cholesky_solve	paddle.Tensor.cholesky_solve	修改文档参数
59	torch.Tensor.triangular_solve	paddle.Tensor.triangular_solve	修改文档分类
60	torch.autograd.enable_grad	paddle.enable_grad	增加文档
61	torch.autograd.set_grad_enabled	paddle.set_grad_enabled	增加文档

torch.linalg.eigh 返回值符号不同
image

torch.linalg.svd 返回值符号不同
image

paconvert/api_mapping.json Show resolved Hide resolved
tests/test_Tensor_float_power_.py Outdated Show resolved Hide resolved
tests/test_Tensor_float_power_.py Outdated Show resolved Hide resolved
tests/test_Tensor_symeig.py Show resolved Hide resolved
tests/test_linalg_eigh.py Outdated Show resolved Hide resolved
tests/test_linalg_eigvalsh.py Outdated Show resolved Hide resolved
tests/test_linalg_matrix_norm.py Show resolved Hide resolved
paconvert/api_mapping.json Show resolved Hide resolved
Copy link

paddle-bot bot commented Nov 10, 2023

Thanks for your contribution!

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.

注意单测不能屏蔽

obj.run(pytorch_code, ["result"])


def _test_case_4():
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
Collaborator Author

@co63oc co63oc Nov 15, 2023

Choose a reason for hiding this comment

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

  1. symeig 会转为 eigh,eigh 返回值符号不同
  2. pytorch 1.9 以上不支持
    image

obj = APIBase("torch.linalg.eigh")


def _test_case_1():
Copy link
Collaborator

Choose a reason for hiding this comment

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

这些单测为何都屏蔽了?是Matcher写的不对吗

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

torch.linalg.eigh 返回值符号不同

image

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
Collaborator Author

@co63oc co63oc Nov 16, 2023

Choose a reason for hiding this comment

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

已修改,测试发现是 paddle cpu和gpu版本计算结果符号不同,cpu版本没有问题

obj = APIBase("torch.linalg.svd")


def _test_case_1():
Copy link
Collaborator

Choose a reason for hiding this comment

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

这些单测为何都屏蔽了?是Matcher写的不对吗

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

torch.linalg.svd 返回值符号不同
image

Copy link
Collaborator

Choose a reason for hiding this comment

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

建议可以索引取出相同的值,对于符号不同的,测paddle.abs()的结果。

测结果可以稍灵活点,但肯定不能不测

Copy link
Collaborator Author

@co63oc co63oc Nov 16, 2023

Choose a reason for hiding this comment

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

已修改,测试发现是 paddle cpu和gpu版本计算结果符号不同,cpu版本没有问题

obj = APIBase("torch.symeig", is_aux_api=True)


def _test_case_1():
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
Collaborator Author

@co63oc co63oc Nov 15, 2023

Choose a reason for hiding this comment

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

  1. symeig 会转为 eigh,eigh 返回值符号不同
  2. pytorch 1.9 以上不支持

@zhwesky2010
Copy link
Collaborator

@co63oc 辛苦再修改一下

@co63oc
Copy link
Collaborator Author

co63oc commented Nov 16, 2023

已修改

@co63oc
Copy link
Collaborator Author

co63oc commented Nov 16, 2023

@zhwesky2010 No.47
image
paddleslim中搜索对应API都是没有,不知道是什么问题

比如搜索 RandomUnstructured https://github.com/search?q=repo%3APaddlePaddle%2FPaddleSlim%20RandomUnstructured&type=code
image

@zhwesky2010
Copy link
Collaborator

@zhwesky2010 No.47 image paddleslim中搜索对应API都是没有,不知道是什么问题

比如搜索 RandomUnstructured https://github.com/search?q=repo%3APaddlePaddle%2FPaddleSlim%20RandomUnstructured&type=code image

只是推测的可能位置,不做具体实现用。
具体实现时,还需要自行调研是否有 相应的功能位置 或者 组合替代方式,如果实在无法实现,则取消相应题目。

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.

有一些小问题,后面改下吧,先approve了

paconvert/api_mapping.json Show resolved Hide resolved
paconvert/api_mapping.json Show resolved Hide resolved
import torch
x = torch.tensor([[1, 2], [2, 1]]).to(dtype=torch.float32)
out = torch.tensor([])
result = torch.linalg.pinv(x, atol=None, rtol=1e-5, hermitian=False, out=out)
Copy link
Collaborator

Choose a reason for hiding this comment

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

可以测一个全部非关键字的

tests/test_pca_lowrank.py Show resolved Hide resolved
@zhwesky2010 zhwesky2010 merged commit f55e8d7 into PaddlePaddle:master Nov 16, 2023
8 checks passed
@luotao1 luotao1 changed the title 【Hackathon 5th No.44】API转换 42-61 【Hackathon 5th No.44】API转换 42-61 -part Nov 16, 2023
@co63oc
Copy link
Collaborator Author

co63oc commented Nov 16, 2023

修改PR #329

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor External developers
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants