-
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
Add diff op #37441
Add diff op #37441
Conversation
Thanks for your contribution! |
the 3rd example's output should be [[3, 3, 3]] ? |
ok, ths, I'll fix it |
2d46ee7
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
python/paddle/tensor/math.py
Outdated
@@ -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): |
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.
in order to align to other apis, we shall use axis instand of dim
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
out[i] = x[i+1] - x[i] | ||
|
||
Higher-order differences are computed by using paddle.diff() recursively. | ||
Only n=1 is currently supported. |
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.
这里用 note 的格式,加强提醒。
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.
LG API
* 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
PR types
New features
PR changes
OPs
Describe
add
paddle.diff()
OP,support CPU and GPU.