According to the SparseArrayKit.jl documentation, sparse tensors implemented therein are compatible with the @tensor macro from the TensorOperations.jl package. The following simple code
function randn_sparse(T::Type{<:Number}, sz::Dims, p=0.5)
a = SparseArray{T}(undef, sz)
for I in keys(a)
if rand() < p
a[I] = randn(T)
end
end
return a
end
X = randn_sparse(Float64, (L, L, L)) # Three-dimensional random tensor
O = ones(L)
@tensor begin
C[i,j] := X[i, j, k] * O[k]
end
returns the error
MethodError: no method matching StridedViews.StridedView(::SparseArray{Float64, 3})
Does anyone know how to fix this ?