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 diff op #37441

Merged
merged 7 commits into from
Nov 30, 2021
Merged

Add diff op #37441

merged 7 commits into from
Nov 30, 2021

Conversation

andyjiang1116
Copy link
Contributor

@andyjiang1116 andyjiang1116 commented Nov 22, 2021

PR types

New features

PR changes

OPs

Describe

add paddle.diff() OP,support CPU and GPU.

截屏2021-11-30 上午9 30 34

截屏2021-11-30 上午9 30 44

@paddle-bot-old
Copy link

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

MissPenguin
MissPenguin previously approved these changes Nov 29, 2021
fuyinno4
fuyinno4 previously approved these changes Nov 29, 2021
@jeff41404
Copy link
Contributor

the 3rd example's output should be [[3, 3, 3]] ?

@andyjiang1116
Copy link
Contributor Author

the 3rd example's output should be [[3, 3, 3]] ?

ok, ths, I'll fix it

jeff41404
jeff41404 previously approved these changes Nov 30, 2021
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

@@ -2611,3 +2611,166 @@ def atan2(x, y, name=None):
helper.append_op(
type='atan2', inputs=inputs, outputs={'Out': out})
return out


def diff(x, n=1, dim=-1, prepend=None, append=None, name=None):
Copy link
Contributor

Choose a reason for hiding this comment

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

in order to align to other apis, we shall use axis instand of dim

Copy link
Contributor

@TCChenlong TCChenlong left a comment

Choose a reason for hiding this comment

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

LGTM

out[i] = x[i+1] - x[i]

Higher-order differences are computed by using paddle.diff() recursively.
Only n=1 is currently supported.
Copy link
Contributor

Choose a reason for hiding this comment

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

这里用 note 的格式,加强提醒。

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

@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

@jeff41404 jeff41404 merged commit 2f4c089 into PaddlePaddle:develop Nov 30, 2021
Zjq9409 pushed a commit to Zjq9409/Paddle that referenced this pull request Dec 10, 2021
* add diff op, test=develop

* rm some notes, test=develop

* update diff doc

* update sample code

* fix diff api params and example code, test=develop
@andyjiang1116 andyjiang1116 deleted the add_diff_op branch May 15, 2023 07:41
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.

6 participants