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

SpM 数据表示中第 0 行为空的情况 #6

Closed
zZzZ9zZ9 opened this issue Dec 19, 2024 · 2 comments
Closed

SpM 数据表示中第 0 行为空的情况 #6

zZzZ9zZ9 opened this issue Dec 19, 2024 · 2 comments
Assignees
Labels
question Further information is requested

Comments

@zZzZ9zZ9
Copy link

假设SPM的第一行所有元素都为0,那么ptr[0]是多少?如果ptr[0]是0的话那不就还是包含了第一个元素?(虽然没有影响测试数据通过,但是感觉表示方法有bug)或者说测试样例里面都保证了SpM第一行一定有一个值?

@KEKE046
Copy link
Collaborator

KEKE046 commented Dec 19, 2024

是的,保证 SpM 第一行至少有一个值。这是本次 lab 的 spmm 格式的缺陷,第一行不能为空。
这样设计的原因是为了把 ptr 数组每个元素的值 fit 到 $2 \log_2 n$ 的位宽。README 中也说到:

下面的图展示了 **COO****CSR** 格式的对比。**COO** 格式指将矩阵中所有的非零元素按 (row, col, data) 排列成一个列表。可以发现,row 数组里有大量冗余,表现是有很多连续且相同的元素。**CSR** 格式不记录 row 的数组,而是对行做索引。用一个 ptr 数组记录每一行的结束元素所在位置(更标准的是记录开始元素,但在这个 lab 里我们考虑结束元素)。

更标准的是记录开始元素,但在这个 lab 里我们考虑结束元素

@KEKE046 KEKE046 self-assigned this Dec 19, 2024
@KEKE046 KEKE046 added the question Further information is requested label Dec 19, 2024
@KEKE046 KEKE046 pinned this issue Dec 19, 2024
@zZzZ9zZ9
Copy link
Author

Thx!

@KEKE046 KEKE046 changed the title SpM数据表示 SpM 数据表示中第 0 行为空的情况 Dec 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants