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 5th No.110】为 Paddle 增强 sparse.matmul API #721

Merged
merged 11 commits into from Nov 16, 2023

Conversation

MayYouBeProsperous
Copy link
Contributor

@MayYouBeProsperous MayYouBeProsperous commented Oct 25, 2023

题目:链接

@paddle-bot
Copy link

paddle-bot bot commented Oct 25, 2023

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

## PyTorch
Pytorch 的稀疏矩阵乘法的实现代码的位置在 `pytorch/aten/src/ATen/native/sparse/SparseMatMul.cpp`。

函数 `sparse_matmul_kernel` 在计算稀疏矩阵乘法时,会将两个相乘的矩阵统一为 `CSR` 模式,再进行计算,得到 `CSR` 模式的计算结果。如果想要获得 `COO` 模式的计算结果,需将 `CSR` 模式转化为 `COO` 模式。
Copy link
Contributor

Choose a reason for hiding this comment

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

后面这句话写的不太对

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的已修改


```cpp
template <typename scalar_t>
void sparse_matmul_kernel(
Copy link
Contributor

Choose a reason for hiding this comment

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

竞品的COO*COO、CSR*CSR的实现方式写详细一些,比如调用了什么库实现

Copy link
Contributor Author

Choose a reason for hiding this comment

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

好的已修改



## TensorFlow
TensorFlow 的稀疏矩阵乘法的实现代码的位置在 `tensorflow\core\kernels\sparse\sparse_mat_mul_op.cc`。
Copy link
Contributor

Choose a reason for hiding this comment

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

COO*COO、CSR*CSR分开写一下

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.


API 主要通过调用 `cudaSparse` 库完成计算实现,目前暂不需要开发 CPU kernel。

`cudaSparse` 库的 `cusparseSpGEMM` 只支持 `CSR*CSR` 模式,在计算 `COO*COO` 模式时,需要进行 `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.

反向如何实现也写一下

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done.

@zhwesky2010 zhwesky2010 merged commit c66906b into PaddlePaddle:master Nov 16, 2023
1 check passed
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.

None yet

3 participants