-
Notifications
You must be signed in to change notification settings - Fork 5.6k
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 "eigvals" in linalg #35720
Conversation
… add-linalg-eigvals-API
… add-linalg-eigvals-API
Thanks for your contribution! |
.. code-block:: python | ||
|
||
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.
Add paddle.seed(x) to fix output.
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
def np_eigvals_grad(a, out_grad): | ||
l, v = np.linalg.eig(a) | ||
print("l:") | ||
print(l) | ||
print("v:") | ||
print(v) | ||
vh = v.conj().T | ||
print("vh:") | ||
print(vh) | ||
print("out_grad:") | ||
print(out_grad) | ||
a_grad = np.linalg.solve(vh, np.diagflat(out_grad, 0) * vh) | ||
print("a_grad") | ||
print(a_grad) | ||
|
||
return a_grad.astype(a.dtype) |
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.
seems no usage.
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.
It has been commented out.
paddle/fluid/operators/eigvals_op.h
Outdated
template <typename T> | ||
using EigenVectorStd = Eigen::Matrix<StdCType<T>, Eigen::Dynamic, 1>; | ||
|
||
static void SpiltBatchSquareMatrix(const Tensor *input, |
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.
Better use const& for input
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
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
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 set_tests_properties(test_eigvals_op PROPERTIES TIMEOUT 400)
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
TODO:
1、补充中文文档&中英文API文档预览图
2、示例代码中不需要set_device这一行
* Add linalg.eigvals API * pre-commit check * Adjust code style * Fix conflict * Improve code style * Modify the test code to ignore testing CUDA kernel * Sort ouput data before checking in test code * Set timeout value for UT * Improve API example code to pass CI * Fix bug for None fetch_list in Windows * Delete grad Op
PR types
New features
PR changes
APIs
Describe
Add a new API: linalg.eigvals
The corresponding PR for CN docs:PaddlePaddle/docs#3875
NOTE