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 7th No.37】为 Paddle 代码转换工具新增 API 转换规则(第 4 组) #6884

Open
wants to merge 5 commits into
base: develop
Choose a base branch
from

Conversation

monster1015
Copy link
Contributor

No description provided.

@monster1015
Copy link
Contributor Author

image
请问这是说我代码风格不对吗?
@luotao1

@monster1015
Copy link
Contributor Author

@sunzhongkai588

@luotao1
Copy link
Collaborator

luotao1 commented Sep 23, 2024

是的,请根据日志里的提示用precommit修改代码格式。

@monster1015
Copy link
Contributor Author

是的,请根据日志里的提示用precommit修改代码格式。

好的,请稍等

@monster1015
Copy link
Contributor Author

已经好了,劳烦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)
Copy link
Collaborator

Choose a reason for hiding this comment

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

paddle也有类方法 paddle.Tensor.gammainc

类方法 尽量对应到 类方法,实在没有类方法,才对应到非类方法

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
Collaborator

@zhwesky2010 zhwesky2010 Sep 24, 2024

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

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

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

Choose a reason for hiding this comment

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

同上


| PyTorch | PaddlePaddle | 备注 |
| ------- | ------------ | --------------------------- |
| - | x | 输入的方阵,类型为 Tensor。 |
Copy link
Collaborator

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

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

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

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类型的

Copy link
Contributor Author

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 无此参数,需要转写。 |
Copy link
Collaborator

Choose a reason for hiding this comment

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

如果是返回值不同,应该在下面再加一行:

infoflow 2024-09-23 15-53-21

@monster1015
Copy link
Contributor Author

@zhwesky2010 已经修改好了,PaConvert也已经同步修改了

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.

注意参数映射栏:先简述参数功能,再描述差异

out = x.igamma(y)

# Paddle 写法
out = .gammainc(y)
Copy link
Collaborator

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

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

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

Choose a reason for hiding this comment

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

一比一对照模板写

@@ -0,0 +1,30 @@
<!--
Copy link
Collaborator

Choose a reason for hiding this comment

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

这些删掉


| PyTorch | PaddlePaddle | 备注 |
| ------------- | ------------ | ------------------------------------------------------ |
| input2 | tau | 仅参数名字不一致 |
Copy link
Collaborator

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

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

Choose a reason for hiding this comment

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

同上


| PyTorch | PaddlePaddle | 备注 |
| --------- | ------------ | ---------------------- |
| input | x | 仅参数名字不一致 |
Copy link
Collaborator

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 无此参数,需转写 |
Copy link
Collaborator

Choose a reason for hiding this comment

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

均同上

@zhwesky2010
Copy link
Collaborator

后续注意根据文档来实现Matcher,注意不要出现文档与Matcher的diff。

如果实现Matcher的过程中,发现文档有误,需及时更正文档

@monster1015
Copy link
Contributor Author

后续注意根据文档来实现Matcher,注意不要出现文档与Matcher的diff。

如果实现Matcher的过程中,发现文档有误,需及时更正文档

抱歉,写的时候有点着急,不过这次可以了的

| ------------ | ------------ | ---------------------------------------------------------------------------------------------------------------------------------------------------- |
| input | x | 表示输入参数为多维 Tensor,它的维度应该为 [*, M, N],其中*为零或更大的批次尺寸,并且最里面的两个维度上的矩阵都应为对称的正定矩阵,仅参数名不一致。 |
| upper | upper | 表示是否返回上三角矩阵或下三角矩阵。 |
| check_errors | - | 是否检查错误,paddle 暂不支持。 |
Copy link
Collaborator

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

@zhwesky2010 zhwesky2010 Sep 27, 2024

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 时的情况
Copy link
Collaborator

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 暂不支持 |
Copy link
Collaborator

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 时的情况
Copy link
Collaborator

Choose a reason for hiding this comment

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

check_errors是否支持转写,要写清楚

Copy link
Contributor Author

Choose a reason for hiding this comment

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

已经弄好了,单侧也已经好了

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
contributor PaddlePaddle Hackathon 飞桨黑客松活动issue与PR
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants