【Hackathon 4th No.30】为 Paddle 新增 paddle.sparse.sum 稀疏 API#411
Merged
Conversation
5 tasks
Member
Author
|
实现进度 |
zhwesky2010
reviewed
Mar 9, 2023
|
|
||
| ``` | ||
|
|
||
| 相应的InferMeta函数可以复用稠密矩阵的函数。 |
Contributor
There was a problem hiding this comment.
这个应该没办法简单复用,因为还涉及到一个indices、values的shape
Member
Author
There was a problem hiding this comment.
这里我好像有些不太理解,我参考了稀疏矩阵另外已经实现的其他几个infermeta函数,
void Conv3dInferMeta(const MetaTensor& x,
const MetaTensor& kernel,
const std::vector<int>& paddings,
const std::vector<int>& dilations,
const std::vector<int>& strides,
const int groups,
const bool subm,
const std::string& key,
MetaTensor* out,
MetaTensor* rulebook,
MetaTensor* counter) 看到输入为metatensor,但其中只有这三个方法
virtual void set_dims(const DDim& dims);
virtual void set_dtype(DataType dtype);
virtual void set_layout(DataLayout layout);但是indices、values的shape应该是在SparseTensor里的参数,那我是否应该在这里传入SparseTensor,这样的话感觉似乎不太符合infermeta的机制了
| rtol=1e-05, | ||
| ) | ||
|
|
||
| def test_sum_2d(self): |
zhwesky2010
reviewed
Mar 14, 2023
| SumInferMeta函数 将优先根据dtype。 | ||
|
|
||
| ## 底层OP设计 | ||
| 对于COO格式和CSR格式axis=None的简单情况,只需要把value值求和,并对相应的位置参数进行修改即可。 |
Contributor
There was a problem hiding this comment.
axis=None时,应该就返回一个DenseTensor了,这个时候只有一个元素,也就无所谓Sparse还是Dense了
Member
Author
There was a problem hiding this comment.
那这里的kernel是不是需要实现两个,一个返回稀疏矩阵一个返回dense矩阵,或者有其他的办法,因为这里的机制我还不太了解,所以在设计时就只考虑了输出只为稀疏矩阵的情况
Contributor
There was a problem hiding this comment.
还是返回稀疏Tensor吧,但是只有一个元素的稀疏Tensor
Member
Author
zhwesky2010
reviewed
Mar 28, 2023
| @@ -0,0 +1,430 @@ | |||
| # paddlesparse.sum 设计文档 | |||
Contributor
There was a problem hiding this comment.
paddlesparse.sum 设计文档。这些没写对,尽量避免语法错误
Member
Author
There was a problem hiding this comment.
好的,这里已修改,刚刚检查了一下,应该没有类似的错误了
zhwesky2010
approved these changes
Mar 28, 2023
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.



任务说明 https://github.com/PaddlePaddle/community/blob/master/hackthon_4th/%E3%80%90PaddlePaddle%20Hackathon%204%E3%80%91%20%E6%A0%B8%E5%BF%83%E6%A1%86%E6%9E%B6%E5%BC%80%E6%BA%90%E8%B4%A1%E7%8C%AE%20API%20%E5%BC%80%E5%8F%91%E4%BB%BB%E5%8A%A1%E5%90%88%E9%9B%86.md#task30