spikingjelly.cext.functional package¶
Module contents¶
- class spikingjelly.cext.functional.sparse_mm_dense_atf[源代码]¶
基类:
torch.autograd.function.Function
- static forward(ctx, sparse: torch.Tensor, dense: torch.Tensor)[源代码]¶
- spikingjelly.cext.functional.sparse_mm_dense(sparse: torch.Tensor, dense: torch.Tensor)[源代码]¶
-
- 参数
sparse (torch.Tensor) – 稀疏2D tensor
dense (torch.Tensor) – 稠密2D tensor
- 返回
sparse 和 dense 的矩阵乘
- 返回类型
对输入的稀疏的二维矩阵
sparse
和稠密的二维矩阵dense
进行矩阵乘法。警告
代码内部的实现方式是,首先将
sparse
转换为稀疏矩阵格式,然后再调用相关库进行运算。如果sparse
不够稀疏,则该函数的速度会比普通矩阵乘法torch.mm
慢很多。警告
稀疏矩阵的乘法存在一定的计算误差,但误差并不显著,或可忽略。
警告
本函数不支持CPU。
- 参数
sparse (torch.Tensor) – a 2D sparse tensor
dense (torch.Tensor) – a 2D dense tensor
- 返回
a matrix multiplication of the matrices
dense
andsparse
- 返回类型
Performs a matrix multiplication of the matrices
dense
andsparse
.Warning
This function is implemented by converting
sparse
to a sparse format and doing a sparse matrix multiplication. If the sparsity ofsparse
is not high enough, the speed of this function will be slower thantorch.mm
.Warning
There are some numeral errors when doing the sparse matrix multiplication. But the errors are not significant.
Warning
This function does not support to run on cpu.