-
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
【Hackathon 6th No.4】Add Ormqr API to Paddle -part #63227
Conversation
你的PR提交成功,感谢你对开源项目的贡献! |
好的,现在已经更新了 |
等PR其他功能review完成后,这块会安排approve |
是的 |
Sorry to inform you that 9498200's CIs have passed for more than 7 days. To prevent PR conflicts, you need to re-run all CIs manually. |
@lxd-cumt 我已经按照邮件说的重新跑了一次ci了 |
python/paddle/tensor/linalg.py
Outdated
), "The input and tau and other parameters should have the same batch" | ||
m, n = input.shape[-2:] | ||
|
||
def _ormqr_Q(input, tau): |
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.
这是在计算Q=householder_product(input, tau)吗,householder_product 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.
是可以复用的,那我现在把他提出来把
python/paddle/tensor/linalg.py
Outdated
), "The input and tau and other parameters should have the same batch" | ||
m, n = input.shape[-2:] | ||
|
||
def _ormqr_Q(input, tau): |
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.
建议看一下框架中已有的 householder_product 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.
他的整个逻辑就是householder_product+matmul
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.
现在已经弄好了
self.other = np.random.randn(3, 4).astype('float64') | ||
|
||
|
||
class TestOrmqrAPICase3(TestOrmqrAPI): |
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.
这个和上一个TestCase2有什么区别吗
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.
是检查支持的数据类型的,一个是float32,一个是float64
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.
TestCase2和TestCase3 好像dtype是一样的,shape不一样,这个shape是有什么边界情况吗
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.
这个没有,只是多几个例子看看效果对不对的上
已经好了 @luotao1 @jeff41404 |
对应的RFC也需要改下 |
已经改过了 |
python/paddle/tensor/linalg.py
Outdated
@@ -5038,3 +5040,93 @@ def __check_ranges(D, ranges): | |||
hist /= s | |||
|
|||
return (hist, edges) | |||
|
|||
|
|||
def ormqr(x, tau, other, left=True, transpose=False, name=None): |
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.
Accroding to API design guidelines standard, other
should be replaced by y
, everything else is fine
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.
Ok, I‘ve modified, please review
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.
rfc也同步修改了 @luotao1
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.
- 英文文档写作规范参考 https://www.paddlepaddle.org.cn/documentation/docs/zh/dev_guides/api_contributing_guides/api_docs_guidelines_cn.html#yingwenmuban
- 一些 sphinx 语法细节需要注意,可以看看预览有没有什么其他不对的地方 http://preview-paddle-pr-63227.paddle-docs-preview.paddlepaddle.org.cn/documentation/docs/en/api/paddle/linalg/ormqr_en.html
python/paddle/tensor/linalg.py
Outdated
Returns: | ||
Tensor - data type and shape are the same as y. |
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.
Returns: | |
Tensor - data type and shape are the same as y. | |
Returns: | |
Tensor. Data type and shape are the same as y. |
python/paddle/tensor/linalg.py
Outdated
x (Tensor) - shape(*,mn, k), When left is True, the value of mn is equal to m, otherwise the value of mn is equal to n. * indicates that the length of the tensor on axis 0 is 0 or greater. | ||
tau (Tensor) - shape (*, min(mn, k)), where * indicates that the length of the Tensor on axis 0 is 0 or greater, and its type is the same as input. | ||
y (Tensor) - shape (*m,n), where * indicates that the length of the Tensor on axis 0 is 0 or greater, and its type is the same as input. | ||
left (bool, optional) - Determines the order in which the matrix product operations are operated. If left is true, the order of evaluation is op(Q) * y, otherwise, the order of evaluation is y * op(Q). Default value: True. | ||
transpose (bool, optional) - If true, the matrix Q is conjugated and transposed, otherwise, the conjugate transpose transformation is not performed. Default value: False. | ||
name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None. |
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.
x (Tensor) - shape(*,mn, k), When left is True, the value of mn is equal to m, otherwise the value of mn is equal to n. * indicates that the length of the tensor on axis 0 is 0 or greater. | |
tau (Tensor) - shape (*, min(mn, k)), where * indicates that the length of the Tensor on axis 0 is 0 or greater, and its type is the same as input. | |
y (Tensor) - shape (*m,n), where * indicates that the length of the Tensor on axis 0 is 0 or greater, and its type is the same as input. | |
left (bool, optional) - Determines the order in which the matrix product operations are operated. If left is true, the order of evaluation is op(Q) * y, otherwise, the order of evaluation is y * op(Q). Default value: True. | |
transpose (bool, optional) - If true, the matrix Q is conjugated and transposed, otherwise, the conjugate transpose transformation is not performed. Default value: False. | |
name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None. | |
x (Tensor): Shape(\*,mn, k), when left is True, the value of mn is equal to m, otherwise the value of mn is equal to n. \* indicates that the length of the tensor on axis 0 is 0 or greater. | |
tau (Tensor): Shape (\*, min(mn, k)), where \* indicates that the length of the Tensor on axis 0 is 0 or greater, and its type is the same as input. | |
y (Tensor): Shape (\*m,n), where \* indicates that the length of the Tensor on axis 0 is 0 or greater, and its type is the same as input. | |
left (bool, optional): Determines the order in which the matrix product operations are operated. If left is true, the order of evaluation is op(Q) \* y, otherwise, the order of evaluation is y \* op(Q). Default value: True. | |
transpose (bool, optional): If true, the matrix Q is conjugated and transposed, otherwise, the conjugate transpose transformation is not performed. Default value: False. | |
name (str, optional): For details, please refer to :ref:`api_guide_Name`. Generally, no setting is required. Default: None. |
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
@Chen-Lun-Hao 请提交对应的中文文档 |
|
PaddlePaddle/docs#6587 已经提交,请review |
* ormqr API * update * test * update code style * update ormqr api * code_style * update check * update ormqr * finish * finish * finish * update code_style * update * finish * update name * update * update information * update * update * Update python/paddle/tensor/linalg.py --------- Co-authored-by: zachary sun <70642955+sunzhongkai588@users.noreply.github.com>
PR Category
Others
PR Types
Others
Description
Add Ormqr API to Paddle