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

Add new API cholesky_solve #38167

Merged
merged 1 commit into from
Dec 24, 2021
Merged

Add new API cholesky_solve #38167

merged 1 commit into from
Dec 24, 2021

Conversation

zhiboniu
Copy link
Contributor

@zhiboniu zhiboniu commented Dec 15, 2021

PR types

New features

PR changes

APIs

Describe

Add new API cholesky_solve

import paddle
import numpy as np


u = paddle.to_tensor([[1, 1, 1], 
​                        [0, 2, 1],
​                        [0, 0,-1]], dtype="float64")
b = paddle.to_tensor([[0], [-9], [5]], dtype="float64")
out = paddle.linalg.cholesky_solve(b, u, upper=True)

  Tensor(shape=[3, 1], dtype=float64, place=CUDAPlace(0), stop_gradient=True,
  ​       [[-2.50000000],
  ​        [-7.        ],
  ​        [ 9.50000000]])

备注:
修改op 反向测试精度原因:
线性代数相关API,反向实现通常由各种矩阵操作组合,这些操作依赖paddle底层Tensor操作,通常与numpy实现误差达不到1e-5的要求,这是线性代数共性问题。

@paddle-bot-old
Copy link

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

int *devInfo);

template <>
void cusolver_potrs<float>(const cusolverDnHandle_t &cusolverH,
Copy link
Contributor

@jeff41404 jeff41404 Dec 21, 2021

Choose a reason for hiding this comment

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

shall we also support cusolver_potrs<platform::complex<float>> and cusolver_potrs<platform::complex<double>>?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

用于boardcast 输入Tensor的TensorExpand操作暂不支持复数,所以先不注册复数类型。底层代码逻辑实现考虑了复数情况。

Comment on lines +164 to +165
ops::CholeskySolveKernel<paddle::platform::CPUDeviceContext, float>,
ops::CholeskySolveKernel<paddle::platform::CPUDeviceContext, double>);
Copy link
Contributor

@jeff41404 jeff41404 Dec 21, 2021

Choose a reason for hiding this comment

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

register kernel of platform::complex<float> and platform::complex<double> ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

用于boardcast 输入Tensor的TensorExpand操作暂不支持复数,所以先不注册复数类型。底层代码逻辑实现考虑了复数情况。

Comment on lines +169 to +170
ops::CholeskySolveGradKernel<paddle::platform::CPUDeviceContext, float>,
ops::CholeskySolveGradKernel<paddle::platform::CPUDeviceContext, double>);
Copy link
Contributor

Choose a reason for hiding this comment

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

register kernel of platform::complex<float> and platform::complex<double> ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

用于boardcast 输入Tensor的TensorExpand操作暂不支持复数,所以先不注册复数类型。底层代码逻辑实现考虑了复数情况。

lanxianghit
lanxianghit previously approved these changes Dec 21, 2021
jeff41404
jeff41404 previously approved these changes Dec 21, 2021
Copy link
Contributor

@jeff41404 jeff41404 left a comment

Choose a reason for hiding this comment

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

LGTM

XiaoguangHu01
XiaoguangHu01 previously approved these changes Dec 22, 2021
Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

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

LG API

.. code-block:: python

import paddle
import numpy as np
Copy link
Contributor

Choose a reason for hiding this comment

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

numpy 没用到。

For more information, please refer to :ref:`api_guide_Name`.

Returns:
Tensor: The solution of the system of equations. Its data type should be the same as that of `x`.
Copy link
Contributor

Choose a reason for hiding this comment

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

should be不对吧?这是返回的tensor。

Copy link
Contributor

@jzhang533 jzhang533 left a comment

Choose a reason for hiding this comment

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

lgtm

Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

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

LG API

Copy link
Contributor

@Xreki Xreki left a comment

Choose a reason for hiding this comment

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

LGTM for the change of max_relative_error

@jeff41404 jeff41404 merged commit 39f7c41 into PaddlePaddle:develop Dec 24, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants