willow-ahrens / Finch.jl

Sparse tensors in Julia and more! Datastructure-driven array programing language.
http://willowahrens.io/Finch.jl/
MIT License
157 stars 15 forks source link

Strange Countstored Results on SparseMatrixCSC tensors #483

Closed kylebd99 closed 5 months ago

kylebd99 commented 5 months ago

Hey All,

I'm getting some strange results when I call countstored on SparseMatrixCSC tensors. This came up as I was doing sanity checking on some benchmarks.

A =Tensor(SparseMatrixCSC(sprand(5, 5, .5)));
B =Tensor(SparseMatrixCSC(sprand(5, 5, .5)));
C =Tensor(SparseMatrixCSC(sprand(5, 5, .5)));
D = Tensor(Dense(Sparse(Element(0.0))))
@finch begin  
      D.=0;
      for  j=_,i=_ 
              D[i,j] = (A[i,j] + B[i,j])* C[i,j] 
      end 
end
println(countstored(D))
println(D)

Despite D being non-empty, it's giving a countstored of 0.

willow-ahrens commented 5 months ago

I think countstored is broken on SparseDict format, or perhaps something else is broken in this format