-
Notifications
You must be signed in to change notification settings - Fork 777
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 8th No.1】add lu_solve
api for paddle
#7052
base: develop
Are you sure you want to change the base?
Conversation
感谢你贡献飞桨文档,文档预览构建中,Docs-New 跑完后即可预览,预览链接:http://preview-pr-7052.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/zh/api/index_cn.html |
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.
中文文档还需要更新么?
不用了,该写的都写了 |
- **b** (Tensor) - 输入的欲进行线性方程组求解的右值,类型为 Tensor。 ``b`` 的形状应为 ``[*, M, K]``,其中 ``*`` 为零或更大的批次维度,数据类型为 float32, float64。 | ||
- **lu** (Tensor) - LU 分解结果矩阵,由 L、U 拼接组成,类型为 Tensor。 ``lu`` 的形状应为 ``[*, M, M]``,其中 ``*`` 为零或更大的批次维度。数据类型和 ``b`` 相同。 | ||
- **pivots** (Tensor) - LU 分解结果的主元信息,类型为 Tensor。 ``pivots`` 的形状应为 ``[*, M]``,其中 ``*`` 为零或更大的批次维度。数据类型为 int32。 | ||
- **trans** (str,可选) - 是否对 A 进行转置,默认值为 N。 |
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.
写一下trans的取值?可以是N、T、C
.. math:: | ||
b = A * X | ||
|
||
当 `trans` 为 `T` 时,公式为: |
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.
trans为C时的公式也写下吧
|
||
| PyTorch | PaddlePaddle | 备注 | | ||
| ------- | ------------ | ----------------------------------------------------- | | ||
| B | b | 表示欲进行线性方程组求解的右值 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的为主,第一个是LU
| B | b | 表示欲进行线性方程组求解的右值 Tensor ,仅参数名不一致。 | | ||
| pivots | pivots | 表示 LU 分解结果的主元信息 Tensor 。 | | ||
| LU | lu | 表示 LU 分解结果矩阵,由 L、U 拼接组成,仅参数名不一致。 | | ||
| left | - | 表示待求解向量是否在左侧, 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.
这个可以转写吧,根据你之前的描述,可以利用转置来变换公式,将左边变换到右边
| pivots | pivots | 表示 LU 分解结果的主元信息 Tensor 。 | | ||
| LU | lu | 表示 LU 分解结果矩阵,由 L、U 拼接组成,仅参数名不一致。 | | ||
| left | - | 表示待求解向量是否在左侧, Paddle 无此参数,暂无转写方式。| | ||
| adjoint | trans | 表示是否使用转置 LU 分解结果, PyTorch 为 bool 类型,Paddle 为 str 类型,需要转写。| |
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.
这个应该是共轭转置?adjoint=True时对应tranc='C'
| LU | lu | 表示 LU 分解结果矩阵,由 L、U 拼接组成,仅参数名不一致。 | | ||
| left | - | 表示待求解向量是否在左侧, Paddle 无此参数,暂无转写方式。| | ||
| adjoint | trans | 表示是否使用转置 LU 分解结果, PyTorch 为 bool 类型,Paddle 为 str 类型,需要转写。| | ||
| 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.
有四种情况下的转写,看看是不是这样变换的:
x=torch.linalg.lu_solve(lu, pivots, b) -> x=paddle.lu_solve(b, lu, pivots)
x=torch.linalg.lu_solve(lu, pivots, b, adjoint=True) -> x=paddle.lu_solve(b, lu, pivots, trans=‘C’)
x=torch.linalg.lu_solve(lu, pivots, b, left=False) -> x=paddle.lu_solve(b^H, lu, pivots, trans=‘C’)^H
X A=b -> A^H X^H=b^H
x=torch.linalg.lu_solve(lu, pivots, b, left=False, adjoint=True) -> x=paddle.lu_solve(b^H, lu, pivots)^H
X A^H=b -> A X^H=b^H
paddle.assign(y, A) | ||
``` | ||
|
||
#### adjoint |
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.
adjoint与left的四种组合情况转写
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.
adjoint与left的四种组合情况转写
已经都改好了
No description provided.