-
Notifications
You must be signed in to change notification settings - Fork 737
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 7th No.37】为 Paddle 代码转换工具新增 API 转换规则(第 4 组)-part #6884
Conversation
c7b79d5
to
315b1d4
Compare
|
是的,请根据日志里的提示用precommit修改代码格式。 |
好的,请稍等 |
已经好了,劳烦review一下 |
### [paddle.gammainc](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/gammainc_cn.html#gammainc) | ||
|
||
```python | ||
paddle.gammainc(x, y, name=None) |
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.
paddle也有类方法 paddle.Tensor.gammainc
类方法 尽量对应到 类方法,实在没有类方法,才对应到非类方法
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.
我在查文档的时候并没有找到对应的方法
不要查文档,不以文档为准,以代码为准。直接下一个paddle的源码、或者import一个最新版paddle
### [paddle.gammainc_](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/gammainc__cn.html#gammainc) | ||
|
||
```python | ||
paddle.gammainc_(x, y, name=None) |
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.
同上
### [paddle.gammaincc](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/gammaincc_cn.html#gammaincc) | ||
|
||
```python | ||
paddle.gammaincc(x, y, name=None) |
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.
同上
### [paddle.gammaincc\_](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/gammaincc__cn.html#gammaincc) | ||
|
||
```python | ||
paddle.gammaincc_(x, y, name=None) |
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.
同上
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | --------------------------- | | ||
| - | x | 输入的方阵,类型为 Tensor。 | |
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.
类方法对应到非类方法,不用对比第一个,直接忽略
因此这种不叫参数名不一致
### [paddle.multigammaln_](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/multigammaln__cn.html#multigammaln) | ||
|
||
```python | ||
paddle.multigammaln_(x, p, name=None) |
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.
paddle.Tensor.multigammaln_
### [paddle.linalg.householder_product](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.6/api/paddle/linalg/householder_product_cn.html#householder-product) | ||
|
||
```python | ||
paddle.linalg.householder_product(x, tau, name=None) |
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.
paddle.Tensor.householder_product
### [paddle.linalg.cholesky](https://www.paddlepaddle.org.cn/documentation/docs/zh/develop/api/paddle/linalg/cholesky_cn.html) | ||
|
||
```python | ||
paddle.linalg.cholesky(x, upper=False, name=None) |
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.
cholesky_ex与cholesky是不是返回值不同,cholesky_ex会多返回一种info类型的
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.
对的,他会多返回一个info
| input | x | 表示输入参数为多维 Tensor,它的维度应该为 [*, M, N],其中*为零或更大的批次尺寸,并且最里面的两个维度上的矩阵都应为对称的正定矩阵,仅参数名不一致。 | | ||
| upper | upper | 表示是否返回上三角矩阵或下三角矩阵。 | | ||
| check_errors | - | 是否检查错误,paddle 暂不支持。 | | ||
| out | - | 表示输出的 Tensor ,Paddle 无此参数,需要转写。 | |
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.
docs/guides/model_convert/convert_from_pytorch/api_difference/linalg/torch.linalg.inv_ex.md
Show resolved
Hide resolved
@zhwesky2010 已经修改好了,PaConvert也已经同步修改了 |
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.
注意参数映射栏:先简述参数功能,再描述差异
out = x.igamma(y) | ||
|
||
# Paddle 写法 | ||
out = .gammainc(y) |
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掉了
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ------------- | | ||
| other | y | 正参数 Tensor | |
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.
加一个 仅参数名不同
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ------------- | | ||
| other | y | 正参数 Tensor | |
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.
加一个 仅参数名不同,一比一对照模板
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ------------- | | ||
| other | y | 正参数 Tensor | |
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.
一比一对照模板写
@@ -0,0 +1,30 @@ | |||
<!-- |
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.
这些删掉
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------- | ------------ | ------------------------------------------------------ | | ||
| input2 | tau | 仅参数名字不一致 | |
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.
先简述下功能,再表明差异
一比一对照模板写
|
||
```python | ||
# PyTorch 写法 | ||
torch.linalg.cholesky_ex(x, upper=False, out=output) |
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.
|
||
```python | ||
# PyTorch 写法: | ||
torch.linalg.inv_ex(x, out=y) |
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.
同上
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| --------- | ------------ | ---------------------- | | ||
| input | 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.
先简述功能,再描写差异
| other | other | 一致 | | ||
| left | left | 一致 | | ||
| transpose | transpose | 一致 | | ||
| out | - | paddle 无此参数,需转写 | |
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.
均同上
后续注意根据文档来实现Matcher,注意不要出现文档与Matcher的diff。 如果实现Matcher的过程中,发现文档有误,需及时更正文档。 |
抱歉,写的时候有点着急,不过这次可以了的 |
| ------------ | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| input | x | 表示输入参数为多维 Tensor,它的维度应该为 [*, M, N],其中*为零或更大的批次尺寸,并且最里面的两个维度上的矩阵都应为对称的正定矩阵,仅参数名不一致。 | | ||
| upper | upper | 表示是否返回上三角矩阵或下三角矩阵。 | | ||
| check_errors | - | 是否检查错误,paddle 暂不支持。 | |
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.
能否转写 要备注清楚
@@ -0,0 +1,49 @@ | |||
## [ torch 参数更多 ]torch.linalg.cholesky_ex |
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参数更多,因为返回参数不同
torch.linalg.cholesky_ex(x, upper=False) | ||
|
||
# Paddle 写法: | ||
## 注: 仅支持 check_errors=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.
check_errors是否支持转写,要在上面写清楚
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------ | ------------ | --------------------------------------------------------------------- | | ||
| A | x | 输入 Tensor,仅参数名不一致。 | | ||
| check_errors | - | 是否检查错误,paddle 暂不支持 | |
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.linalg.inv_ex(x) | ||
|
||
# Paddle 写法: | ||
## 注: 仅支持 check_errors=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.
check_errors是否支持转写,要写清楚
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.Tensor.orgqr(input2) | ||
``` | ||
|
||
### [paddle.Tensor.householder_product](https://www.paddlepaddle.org.cn/documentation/docs/zh/2.6/api/paddle/linalg/householder_product_cn.html#householder-product) |
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.
这些2.6统一都换成develop版本的
|
||
|
||
# Paddle 写法 | ||
paddle.assign((paddle.linalg.cholesky(x, upper=False), paddle.zeros(x.shape[:-2], dtype='int64')),output) |
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.
这个语法上就不对,assign一次只能一个
| ------------ | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
| input | x | 表示输入参数为多维 Tensor,它的维度应该为 [*, M, N],其中*为零或更大的批次尺寸,并且最里面的两个维度上的矩阵都应为对称的正定矩阵,仅参数名不一致。 | | ||
| upper | upper | 表示是否返回上三角矩阵或下三角矩阵。 | | ||
| check_errors | - | 是否检查错误,paddle 暂不支持,需转写,目前仅支持 check_errors 为 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.
| PyTorch | PaddlePaddle | 备注 | | ||
| ------------ | ------------ | --------------------------------------------------------------------- | | ||
| A | x | 输入 Tensor,仅参数名不一致。 | | ||
| check_errors | - | 是否检查错误,paddle 暂不支持,需转写,目前仅支持 check_errors 为 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.
这种参数应该不重要吧?只是增加一个检查而已,转换时直接去掉对网络的计算应该也不会有问题
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.linalg.inv_ex(x, out=y) | ||
|
||
# Paddle 写法: | ||
paddle.assign((paddle.linalg.inv(x), paddle.zeros(x.shape[:-2], dtype='int64')), y) |
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.
一次只能assign一个,语法完全不对
|
||
```python | ||
# PyTorch 写法 | ||
y = torch.special.ndtr(a) |
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.
不需要加个y=
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.special.ndtr(input, *, out=None) | ||
``` | ||
|
||
Paddle 无此 API,需要组合实现。 |
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.
公式已经加了
开发注意事项:
|
我是先写的docs,然后写的matcher,后面再根据matcher改的 |
|
torch.linalg.cholesky_ex(x, upper=False) | ||
|
||
# Paddle 写法: | ||
## 注: 仅支持 check_errors=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.
这个还要吗
torch.linalg.inv_ex(x) | ||
|
||
# Paddle 写法: | ||
## 注: 仅支持 check_errors=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.
这个还要吗
| upper | upper | 表示是否返回上三角矩阵或下三角矩阵。 | | ||
| check_errors | - | 是否检查错误,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
| out | - | 表示输出的 Tensor ,Paddle 无此参数,需要转写。 | | ||
| 返回值 | 返回值 | Pytorch 返回两个 out 与 info,Paddle 仅返回一个 Tensor:out,需转写。 | |
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.
返回值这个还是需要转写的,我的意思是 你不用再注释强调仅支持 check_errors=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.
懂了,那个强调不需要,我都觉得返回值不转写太奇怪了
| A | x | 输入 Tensor,仅参数名不一致。 | | ||
| check_errors | - | 是否检查错误,Paddle 无此参数,一般对网络训练结果影响不大,可直接删除。 | | ||
| out | - | 表示输出的 Tensor , Paddle 无此参数,需要转写。 | | ||
| 返回值 | 返回值 | Pytorch 返回两个 out 与 info,Paddle 仅返回一个 Tensor:out,需转写。 | |
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.
返回值这个还是需要转写的,我的意思是 你不用再注释强调仅支持 check_errors=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.
已经好了的
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
后续注意事项:
- 后续根据该文档来实现Matcher,注意不要出现文档与Matcher的diff。
- 如果实现Matcher的过程中,发现文档有误,需及时回头更正文档。
好的 |
No description provided.