-
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
Support new API linalg.cond in paddle #35140
Conversation
Thanks for your contribution! |
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
from .tensor.linalg import matrix_power # noqa: F401 | ||
from .tensor import inverse as inv # noqa: F401 | ||
from .tensor.linalg import svd | ||
|
||
__all__ = [ | ||
'cholesky', #noqa | ||
'norm', | ||
'cond', |
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.
这里应该和 paddle/init.py 里的 96&496行冲突了,不能同时在两个 all 中
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.
1个API可以有多个别名,但是开放的推荐位置是设计时就唯一确定,比如这个API开放的推荐位置是 paddle.linalg.cond,则其只能加入到相应位置(这里为python/paddle/linalg.py中)的 all 列表中,不能加入到其它的__all__ 列表。
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.
好的,已在python/paddle/init.py中的__all__列表中将'cond'删去了。
python/paddle/tensor/linalg.py
Outdated
import paddle | ||
import numpy as np | ||
np_input = [[1., 0, -1], [0, 1, 0], [1, 0, 1]] | ||
x = paddle.to_tensor(np_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.
567 -> 569 直接改为 x = paddle.to_tensor([[1., 0, -1], [0, 1, 0], [1, 0, 1]])
即可
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
@@ -492,6 +493,7 @@ | |||
'expand_as', | |||
'stack', | |||
'sqrt', | |||
'cond', |
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.
这里不推荐加入到__all__列表,推荐加入到 python/paddle/linalg.py中的__all__列表,原因在下面解释
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 for docs
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
* Support new API linalg.cond in paddle * check code style * check code style * modify codes * add docs_eng of linalg.cond * add svd_norm for linalg.cond * modify docs_en of cond * add support for empty input in dynamic mode * modify set_time of unittest * update * modify unittest of cond * update * remove cond in paddle.__all__ * pull latest codes * merge latest codes * update
PR types
New features
PR changes
APIs
Describe
Support new API 'paddle.linalg.cond' in static/dynamic mode, which can be also called by 'paddle.cond'.
Its doc PR in Chinese is available at PR-3849
docs_cn:
![image](https://user-images.githubusercontent.com/86215757/133579891-939cc127-78b5-4c4a-b3b4-cf565dac5437.png)
Example :