Skip to content
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

Merged
merged 30 commits into from
May 11, 2024
Merged

【Hackathon 6th No.4】Add Ormqr API to Paddle -part #63227

merged 30 commits into from
May 11, 2024

Conversation

ADream-ki
Copy link
Contributor

@ADream-ki ADream-ki commented Apr 3, 2024

PR Category

Others

PR Types

Others

Description

Add Ormqr API to Paddle

Copy link

paddle-bot bot commented Apr 3, 2024

你的PR提交成功,感谢你对开源项目的贡献!
请关注后续CI自动化测试结果,详情请参考Paddle-CI手册
Your PR has been submitted. Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

@paddle-bot paddle-bot bot added the contributor External developers label Apr 3, 2024
@ADream-ki
Copy link
Contributor Author

ADream-ki commented Apr 3, 2024

rfc:PaddlePaddle/community#855

@ADream-ki ADream-ki changed the title 【Hackathon 6th No.4】Add Ormqr API to Paddleormqr API 【Hackathon 6th No.4】Add Ormqr API to Paddle Apr 8, 2024
@luotao1
Copy link
Contributor

luotao1 commented Apr 11, 2024

image 你的分支落后主干太多了,要merge develop

@ADream-ki
Copy link
Contributor Author

好的,现在已经更新了

@ADream-ki
Copy link
Contributor Author

image
这个是需要approve? @luotao1 @lxd-cumt

@luotao1
Copy link
Contributor

luotao1 commented Apr 15, 2024

等PR其他功能review完成后,这块会安排approve

@ADream-ki
Copy link
Contributor Author

好的,那 #63302 这个也是吗?
@luotao1

@luotao1
Copy link
Contributor

luotao1 commented Apr 15, 2024

是的

Copy link

paddle-ci-bot bot commented Apr 21, 2024

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.

@ADream-ki
Copy link
Contributor Author

@lxd-cumt 我已经按照邮件说的重新跑了一次ci了

), "The input and tau and other parameters should have the same batch"
m, n = input.shape[-2:]

def _ormqr_Q(input, tau):
Copy link
Contributor

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里面有这部分逻辑,可以复用吗

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是可以复用的,那我现在把他提出来把

), "The input and tau and other parameters should have the same batch"
m, n = input.shape[-2:]

def _ormqr_Q(input, tau):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

建议看一下框架中已有的 householder_product api,如果逻辑相同,可以复用,这样更利于框架代码维护

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

他的整个逻辑就是householder_product+matmul

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

中间再做一个转置和左乘的判断就好了

Copy link
Contributor Author

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):
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个和上一个TestCase2有什么区别吗

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

是检查支持的数据类型的,一个是float32,一个是float64

Copy link
Contributor

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是有什么边界情况吗

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

这个没有,只是多几个例子看看效果对不对的上

@luotao1 luotao1 added the API label Apr 24, 2024
@ADream-ki
Copy link
Contributor Author

已经好了 @luotao1 @jeff41404

@luotao1
Copy link
Contributor

luotao1 commented May 7, 2024

对应的RFC也需要改下

@ADream-ki
Copy link
Contributor Author

对应的RFC也需要改下

已经改过了

@@ -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):
Copy link
Contributor

@jeff41404 jeff41404 May 7, 2024

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

Copy link
Contributor Author

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

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

rfc也同步修改了 @luotao1

jeff41404
jeff41404 previously approved these changes May 9, 2024
Copy link
Contributor

@jeff41404 jeff41404 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Copy link
Contributor

@sunzhongkai588 sunzhongkai588 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Comment on lines 5059 to 5060
Returns:
Tensor - data type and shape are the same as y.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
Returns:
Tensor - data type and shape are the same as y.
Returns:
Tensor. Data type and shape are the same as y.

Comment on lines 5052 to 5057
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.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
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.

Copy link
Contributor

@sunzhongkai588 sunzhongkai588 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@luotao1 luotao1 changed the title 【Hackathon 6th No.4】Add Ormqr API to Paddle 【Hackathon 6th No.4】Add Ormqr API to Paddle -part May 11, 2024
@luotao1 luotao1 merged commit e5e4242 into PaddlePaddle:develop May 11, 2024
30 of 31 checks passed
@luotao1
Copy link
Contributor

luotao1 commented May 11, 2024

@Chen-Lun-Hao 请提交对应的中文文档

@luotao1
Copy link
Contributor

luotao1 commented May 11, 2024

  • 非常感谢你对飞桨的贡献,我们正在运营一个PFCC组织,会通过定期分享技术知识与发布开发者主导任务的形式持续为飞桨做贡献,详情可见 https://github.com/luotao1 主页说明。
  • 如果你对PFCC有兴趣,请发送邮件至 ext_paddle_oss@baidu.com,我们会邀请你加入~

@ADream-ki
Copy link
Contributor Author

@Chen-Lun-Hao 请提交对应的中文文档

PaddlePaddle/docs#6587 已经提交,请review

co63oc pushed a commit to co63oc/Paddle that referenced this pull request May 11, 2024
* 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>
@ADream-ki
Copy link
Contributor Author

32f08b701de2e4716a0b224602ef1db7 Windows Inference上 test_ormqr 单测会出现随机挂,请尽快修复 @Chen-Lun-Hao https://xly.bce.baidu.com/paddlepaddle/paddle/newipipe/detail/10665327/job/26189209 https://xly.bce.baidu.com/paddlepaddle/paddle/newipipe/detail/10669598/job/26195338 https://xly.bce.baidu.com/paddlepaddle/paddle/newipipe/detail/10665891/job/26190058

好的

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants