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.sparse and three Sparse API #41276

Merged
merged 6 commits into from
Apr 6, 2022

Conversation

zkh2016
Copy link
Contributor

@zkh2016 zkh2016 commented Apr 1, 2022

PR types

New features

PR changes

APIs

Describe

  1. 添加路径:paddle.sparsepaddle.sparse.functionalpaddle.sparse.layer
  2. 添加API:paddle.sparse.sparse_coo_tensor(用于创建COO格式的Sparse Tensor )和 paddle.sparse.sparse_csr_tensor(用于创建CSR格式的Sparse Tensor )
  3. 添加API:paddle.sparse.ReLU

使用例子:

import paddle
from paddle.fluid.framework import _test_eager_guard
# 当前需要在eager模式下使用sparse API,后面会统一去掉
with _test_eager_guard():
   indices = [[0, 1],[0, 1]]
   values = [-1.0, 2.0]
   sparse_x = paddle.sparse.sparse_coo_tensor(indices, values, [2, 2])
   sparse_relu = paddle.sparse.ReLU()
   out = sparse_relu(sparse_x)
   # print(out.non_zero_elements())
   # [0.0, 2.0]

英文文档:
image
image

@paddle-bot-old
Copy link

paddle-bot-old bot commented Apr 1, 2022

你的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.

@zkh2016 zkh2016 merged commit 1dd8272 into PaddlePaddle:develop Apr 6, 2022
zkh2016 pushed a commit to zkh2016/Paddle that referenced this pull request Apr 14, 2022
lanxianghit pushed a commit that referenced this pull request Apr 15, 2022
cherry-pick PR#41276 到 release/2.3

    添加路径:paddle.sparse,paddle.sparse.functional,paddle.sparse.layer
    添加API:paddle.sparse.sparse_coo_tensor(用于创建COO格式的Sparse Tensor )和 paddle.sparse.sparse_csr_tensor(用于创建CSR格式的Sparse Tensor )
    添加API:paddle.sparse.ReLU
lanxianghit pushed a commit that referenced this pull request Apr 15, 2022
…) (#41834)

Add paddle.sparse and three Sparse API (#41276)
Add Sparse API to_dense, to_sparse_coo and values (#41394)
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