-
Notifications
You must be signed in to change notification settings - Fork 5.7k
[paddle.linalg.qr] Add the Qr Operator #35742
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
Conversation
Thanks for your contribution! |
Restore the deleted comma
def qr(x, mode="reduced", name=None): | ||
r""" | ||
Computes the QR decomposition of one matrix or batches of matrice. | ||
Args: |
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.
args 之前加一个空行
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.
Done.
If mode = "r", qr will return a tensor which represents R. | ||
|
||
Examples: | ||
import 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.
import paddle 之前需要加入:.. code-block:: python
参考文档:http://agroup.baidu.com/paddlepaddle/md/article/3088623
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.
Done.
python/paddle/__init__.py
Outdated
@@ -504,6 +505,7 @@ | |||
'sqrt', | |||
'cholesky', | |||
'matrix_power', | |||
'qr', |
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.
线性代数API 不需要在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.
Done.
640915a
python/paddle/__init__.py
Outdated
@@ -105,6 +105,7 @@ | |||
from .tensor.linalg import slogdet # noqa: F401 | |||
from .tensor.linalg import multi_dot # noqa: F401 | |||
from .tensor.linalg import matrix_power # noqa: F401 | |||
from .tensor.linalg import qr # noqa: F401 |
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.
should not add this line, otherwise we have paddle.qr
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
paddle/fluid/operators/qr_op.h
Outdated
compute_q = false; | ||
reduced = true; | ||
} else { | ||
PADDLE_ENFORCE( |
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.
仅CUDA Kernel内的PADDLE_ENFORCE不需要加报错类型,这里也是需要加类型的,而且这里我理解用PADDLE_THROW更合适一些
paddle/fluid/operators/qr_op.h
Outdated
class QrGradKernel : public framework::OpKernel<T> { | ||
public: | ||
void Compute(const framework::ExecutionContext& ctx) const { | ||
PADDLE_ENFORCE( |
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 for ShareDataWith
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.
Discussed that ShareDataWith should not be applied on output tensers, but we are chasing release/2.2 so I will approve this PR and we will change in future PRs
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.
临近打tag,先approve,希望后面追加PR规范报错检查的使用
2fec228
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
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.
LG API
Sorry to inform you that 5356a09's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
PR types
New features
PR changes
OPs
Describe
Add paddle.linalg.qr() function, Qr Op and Qr GPU/CPU kernel.

Note: Qr Op of this pull request doesn't have the backward kernels for now.