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

[Hackathon 3rd No.27 and No.29 ] add paddle.incubate.sparse.any and paddle.incubate.sparse.sum #258

Conversation

OccupyMars2025
Copy link
Contributor

No description provided.

@paddle-bot
Copy link

paddle-bot bot commented Sep 12, 2022

你的PR提交成功,感谢你对开源项目的贡献!
请检查PR提交格式和内容是否完备,具体请参考示例模版
Your PR has been submitted. Thanks for your contribution!
Please check its format and content. For this, you can refer to Template and Demo.

@OccupyMars2025 OccupyMars2025 changed the title [Hackathon 3rd No.23 and No.29 ] add paddle.incubate.sparse.any and paddle.incubate.sparse.sum [Hackathon 3rd No.27 and No.29 ] add paddle.incubate.sparse.any and paddle.incubate.sparse.sum Sep 12, 2022

可以参考[torch.sparse.sum](https://pytorch.org/docs/stable/generated/torch.sparse.sum.html#torch.sparse.sum)
sum算子的python端的代码位于torch\sparse\__init__.py (line 153)
C++端的代码位于aten\src\ATen\native\sparse\SparseTensorMath.cpp (line 1515)
Copy link
Contributor

Choose a reason for hiding this comment

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

这里可以展开大致解读一下C++的代码,尤其是COO/CSR的支持情况 是否都支持,这里都可以展开说下

Copy link
Contributor

Choose a reason for hiding this comment

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

竞品Python API命名需要详细说下


## tensorflow

可以参考 [tf.sparse.reduce_sum](https://www.tensorflow.org/api_docs/python/tf/sparse/reduce_sum) 和 [tf.sparse.reduce_max](https://www.tensorflow.org/api_docs/python/tf/sparse/reduce_max) 的实现
Copy link
Contributor

Choose a reason for hiding this comment

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

同上

def max(x, axis=None, keepdim=False, name=None)
def min(x, axis=None, keepdim=False, name=None)
```
考虑是否增加 output_is_sparse=False 这个参数
Copy link
Contributor

Choose a reason for hiding this comment

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

参考下竞品的API签名


# 附件及参考资料

本 RFC 参考了https://github.com/PaddlePaddle/community/pull/184,在这里对
Copy link
Contributor

Choose a reason for hiding this comment

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

这里是参考了什么内容,可以展开下

静态图实现:目前sparse系列暂不支持静态图

```c
static PyObject* tensor_method_any(TensorObject* self,
Copy link
Contributor

@zhwesky2010 zhwesky2010 Sep 13, 2022

Choose a reason for hiding this comment

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

这个实现既有前向,也有反向,不能像is_same_shape那样,那个返回的是一个bool值,没有构建反向网络 比较简单。这个必须要增加OP kernel

C++实现这里需要重写:kernel名、yaml名、大致算法

@OccupyMars2025
Copy link
Contributor Author

非常感谢飞桨专家的详细解答,我会尽快搞懂后修改提案。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants