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

[Sparse]add sparse unary api(sin/tan/pow/neg/log1p/square/cast...) #44022

Merged
merged 1 commit into from
Jul 12, 2022

Conversation

zhwesky2010
Copy link
Contributor

@zhwesky2010 zhwesky2010 commented Jul 1, 2022

PR types

New features

PR changes

APIs

Describe

增加SparseTensor一元操作API

1. paddle.incubate.sparse.sin(x, name=None)

import paddle
from paddle.fluid.framework import _test_eager_guard

with _test_eager_guard():
    dense_x = paddle.to_tensor([-2., 0., 1.])
    sparse_x = dense_x.to_sparse_coo(1)
    out = paddle.incubate.sparse.sin(sparse_x)

2. paddle.incubate.sparse.nn.Relu() (x, name=None)
3. paddle.incubate.sparse.tan(x, name=None)
4. paddle.incubate.sparse.asin(x, name=None)
5. paddle.incubate.sparse.atan(x, name=None)
6. paddle.incubate.sparse.sinh(x, name=None)
7. paddle.incubate.sparse.tanh(x, name=None)
8. paddle.incubate.sparse.asinh(x, name=None)
9. paddle.incubate.sparse.atanh(x, name=None)
10. paddle.incubate.sparse.sqrt(x, name=None)
11. paddle.incubate.sparse.square(x, name=None)
12. paddle.incubate.sparse.log1p(x, name=None)
13. paddle.incubate.sparse.abs(x, name=None)
14. paddle.incubate.sparse.pow(x, factor, name=None)
15. paddle.incubate.sparse.cast(x, index_dtype=None, value_dtype=None, name=None)
16. paddle.incubate.sparse.neg(x, name=None)

增加乘法、除法scalar的操作

1. paddle.incubate.sparse.multiply(Tensor, scalar)
2. paddle.incubate.sparse.divide(Tensor, scalar)

增加类成员函数nnz

1. paddle.Tensor.nnz():返回SparseTensor中非0元素的个数

@zhwesky2010 zhwesky2010 changed the title unify unary [Sparse] unify unary Jul 1, 2022
@zhwesky2010 zhwesky2010 changed the title [Sparse] unify unary [Sparse]add sparse unary api(sin/tan/pow/neg/log1p/square/cast...) Jul 8, 2022
@zhwesky2010 zhwesky2010 force-pushed the sparse_unary branch 11 times, most recently from 9757dbd to a9c655d Compare July 11, 2022 02:54
GPU,
ALL_LAYOUT,
phi::sparse::DivCsrScalarKernel,
float,
Copy link
Contributor

Choose a reason for hiding this comment

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

这里可以支持下float16

Copy link
Contributor Author

Choose a reason for hiding this comment

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

thx~下个PR改一下

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.

LGTM

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.

4 participants