willow-ahrens / Finch.jl

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

SparseByteMap Follow Protocol Incorrect Results #580

Closed kylebd99 closed 1 month ago

kylebd99 commented 1 month ago

From what I can tell, the sparse byte map level zeros out when you use the follow protocol producing incorrect results.

using Finch

n = 100
data =  fsprand(Int, n, n, .01)
A_sbm = Tensor(SparseByteMap(SparseByteMap(Element(0))), data)
A_d = Tensor(Dense(Dense(Element(0))), data)

C1 = Scalar(0)
C2 = Scalar(0)

@finch begin
    C1 .= 0
    for i=_
         for j=_
             for k=_
                 C1[] += A_sbm[follow(j),i] * A_sbm[k,j]
             end
         end
     end
     C2 .= 0
     for i=_
          for j=_
              for k=_
                C2[] += A_d[j,i] * A_d[k,j]
              end
          end
      end
end

println(C1)
println(C2)