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

Add paddle.linalg.matrix_power OP #34667

Merged
merged 9 commits into from
Aug 20, 2021

Conversation

haolin-nju
Copy link
Contributor

@haolin-nju haolin-nju commented Aug 6, 2021

PR types

New features

PR changes

OPs

Describe

This PR supports matrix_power calculation for linear algorithm module of Paddle. One may call paddle.linalg.matrix_power or paddle.matrix_power to use it.

An example is listed below, which is a python3 script:

import paddle

x = paddle.to_tensor([[1, 2, 3],
                      [1, 4, 9],
                      [1, 8, 27]], dtype='float64')
print(paddle.matrix_power(x, 2))
# [[6.  , 34. , 102.],
#  [14. , 90. , 282.],
#  [36. , 250., 804.]]

print(paddle.matrix_power(x, 0))
# [[1., 0., 0.],
#  [0., 1., 0.],
#  [0., 0., 1.]]

print(paddle.matrix_power(x, -2))
# [[ 12.91666667, -12.75000000,  2.83333333 ],
#  [-7.66666667 ,  8.         , -1.83333333 ],
#  [ 1.80555556 , -1.91666667 ,  0.44444444 ]]

A detailed doc PR in Chinese is now available at docs PR3727. Its preview version is available at matrix_power doc preview before UTC+8 20/08/2021.

@paddle-bot-old
Copy link

paddle-bot-old bot commented Aug 6, 2021

Thanks for your contribution!
Please wait for the result of CI firstly. See Paddle CI Manual for details.

Copy link
Contributor Author

@haolin-nju haolin-nju left a comment

Choose a reason for hiding this comment

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

Resolve comments in matrix_power api.

JiabinYang
JiabinYang previously approved these changes Aug 13, 2021
Copy link
Contributor

@JiabinYang JiabinYang 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 Author

@haolin-nju haolin-nju left a comment

Choose a reason for hiding this comment

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

Need more advice about naming method and comment message.

Copy link
Contributor Author

@haolin-nju haolin-nju left a comment

Choose a reason for hiding this comment

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

Three comments have been resolved in the commit(ce2fa089)

@haolin-nju haolin-nju requested a review from JiabinYang August 16, 2021 02:30
Copy link
Contributor

@JiabinYang JiabinYang 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

@juncaipeng juncaipeng left a comment

Choose a reason for hiding this comment

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

LGTM for changing op_threshold_white_list.py

@haolin-nju haolin-nju requested a review from jzhang533 August 17, 2021 06:53
Copy link
Contributor

@XiaoguangHu01 XiaoguangHu01 left a comment

Choose a reason for hiding this comment

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

LG API

@JiabinYang JiabinYang merged commit e2241a4 into PaddlePaddle:develop Aug 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants