spikingjelly.cext.functional package

Module contents

class spikingjelly.cext.functional.sparse_mm_dense_atf[源代码]

基类:Function

static forward(ctx, sparse: Tensor, dense: Tensor)[源代码]
static backward(ctx, grad_output)[源代码]
spikingjelly.cext.functional.sparse_mm_dense(sparse: Tensor, dense: Tensor)[源代码]
参数
返回

sparse 和 dense 的矩阵乘

返回类型

torch.Tensor

对输入的稀疏的二维矩阵 sparse 和稠密的二维矩阵 dense 进行矩阵乘法。

警告

代码内部的实现方式是,首先将 sparse 转换为稀疏矩阵格式,然后再调用相关库进行运算。如果 sparse 不够稀疏,则该函数的速度会比普通矩阵乘法 torch.mm 慢很多。

警告

稀疏矩阵的乘法存在一定的计算误差,但误差并不显著,或可忽略。

警告

本函数不支持CPU。

参数
返回

a matrix multiplication of the matrices dense and sparse

返回类型

torch.Tensor

Performs a matrix multiplication of the matrices dense and sparse.

Warning

This function is implemented by converting sparse to a sparse format and doing a sparse matrix multiplication. If the sparsity of sparse is not high enough, the speed of this function will be slower than torch.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.