-
Notifications
You must be signed in to change notification settings - Fork 5.7k
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 API paddle.linalg.eig #35674
add API paddle.linalg.eig #35674
Conversation
Update forked PaddlePaddle
Update my fork
update from PaddlePaddle
Update forked paddle repo
Update USERNAME/paddle
update Paddle USERNAME repo
update username repo
update local paddlepaddle
update paddlepaddle
Thanks for your contribution! |
should consider REGISTER_OP_CUDA_KERNEL in order to support CUDA |
As we discussed earlier, I'll do some research to deal with this problem before the end of version 2.2 |
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.
单测框架无法验证的case,考虑可以在op_benchmark中添加脚本,和其他框架前、反向结果对齐。避免以后修改了OP,导致精度出问题
|
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.
功能实现代码没有大问题,但是部分建议没有修改,且部分变量命名不规范,建议后续接着修改
T computed_work_size; | ||
math::lapackEig<T, math::Real<T>>( | ||
jobvl, jobvr, order, input_data, lda, values_data, lvector_data, ldvl, | ||
rvector_data, ldvr, &computed_work_size, lwork, rwork_data, &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.
lvector_data
只是用来作nullptr的话,没必要声明这个变量了
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.
- 该算子只计算右特征向量,所有这里的lvector_data会一直是nullptr。不过为了与LAPACK文档的参数名保持一致,还是保留该变量吧。
- 关于这个函数中的变量名,除了输入输出,其他参数名与LAPACK 文档保持了一致,便于阅读和调试。
- 关于info参数:文档中没有说明在计算computed_work_size时是否会被修改。保险起见应该在此后添加判断。
会在下一步cpu计算,数据传回gpu的支持中考虑修改。
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.
sample code will be improved later.
Roger that. The input data generation in the sample code will be replaced by paddle functions in the following PR: data transfer from cpu to gpu |
* Add paddle.linalg.eig op * remove comments * remove comments * extend batch_size to the origin * add real times complex functor & destroy the backward complex output bug * terminate output diff when input real tensors * correct tiny doc errors * move functions from eig_helper to svd_helper and remove eig_helper * remove tensor.Resize * remove no longer used code * use existing lapack functions * reply review comments 21/27 * remove .cu as this op is only executed on CPU * remove const_cast & add const in argument list for read-only references * fix sample code error in CI * remove template typename Tbase and more * remove eig exposure in paddle.* * add 'name=None' in eig python implementation * handle the unittest * try to solve the unittest * solve CI coverage * remove no longer used code * polish API doc and more * reply review comments * polish unittest, commit plan B * polish unittest
* Add paddle.linalg.eig op * remove comments * remove comments * extend batch_size to the origin * add real times complex functor & destroy the backward complex output bug * terminate output diff when input real tensors * correct tiny doc errors * move functions from eig_helper to svd_helper and remove eig_helper * remove tensor.Resize * remove no longer used code * use existing lapack functions * reply review comments 21/27 * remove .cu as this op is only executed on CPU * remove const_cast & add const in argument list for read-only references * fix sample code error in CI * remove template typename Tbase and more * remove eig exposure in paddle.* * add 'name=None' in eig python implementation * handle the unittest * try to solve the unittest * solve CI coverage * remove no longer used code * polish API doc and more * reply review comments * polish unittest, commit plan B * polish unittest
PR types
New features
PR changes
APIs
Describe
功能
向PaddlePaddle中的线性代数库添加eig算子,该算子计算一般方阵的特征分解。
实现方法
前向实现通过调LAPACK相应的函数,后向计算通过数学原理实现。
效果
分别测试实数数和复数,shape从(3,3)到(6,6,128,128)前向计算符合预期,后向符合预期。其中实数输入时,反向输出最大精度误差为1e-3。
如下是在本地与pytorch.linalg.eig的反向精度对比结果,为方便展示,给出小方阵的结果。附件给出测试脚本:
注意
附件
测试脚本: