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

npz file reader errors #500

Closed albertlu03 closed 4 months ago

albertlu03 commented 4 months ago

reproducing example

ERROR: LoadError: MethodError: Cannot `convert` an object of type Finch.NPYPath to an object of type Vector{Float64}

Closest candidates are:
  convert(::Type{T}, ::T) where T
   @ Base Base.jl:84
  convert(::Type{T}, ::AbstractArray) where T<:Array
   @ Base array.jl:665
  convert(::Type{T}, ::LinearAlgebra.AbstractQ) where T<:AbstractArray
   @ LinearAlgebra ~/.julia/juliaup/julia-1.10.2+0.aarch64.apple.darwin14/share/julia/stdlib/v1.10/LinearAlgebra/src/abstractq.jl:45
  ...

Stacktrace:
  [1] bspread_data(f::Finch.NPYPath, desc::Dict{String, Any}, key::String)
    @ Finch ~/.julia/dev/Finch/src/interface/fileio/binsparse.jl:0
  [2] bspread_level(f::Finch.NPYPath, desc::Dict{String, Any}, fmt::OrderedCollections.OrderedDict{String, String}, ::Val{:element})
    @ Finch ~/.julia/dev/Finch/src/interface/fileio/binsparse.jl:337
  [3] bspread_level(f::Finch.NPYPath, desc::Dict{String, Any}, fmt::OrderedCollections.OrderedDict{String, String})
    @ Finch ~/.julia/dev/Finch/src/interface/fileio/binsparse.jl:329
  [4] bspread_level(f::Finch.NPYPath, desc::Dict{String, Any}, fmt::OrderedCollections.OrderedDict{String, Any}, ::Val{:dense})
    @ Finch ~/.julia/dev/Finch/src/interface/fileio/binsparse.jl:353
  [5] bspread_level(f::Finch.NPYPath, desc::Dict{String, Any}, fmt::OrderedCollections.OrderedDict{String, Any})
    @ Finch ~/.julia/dev/Finch/src/interface/fileio/binsparse.jl:329
  [6] bspread(f::Finch.NPYPath)
    @ Finch ~/.julia/dev/Finch/src/interface/fileio/binsparse.jl:319
  [7] bspread_bspnpy
    @ ~/.julia/dev/Finch/ext/NPZExt.jl:32 [inlined]
  [8] bspread
    @ ~/.julia/dev/Finch/src/interface/fileio/binsparse.jl:300 [inlined]
  [9] fread(filename::String)
    @ Finch ~/.julia/dev/Finch/src/interface/fileio/fileio.jl:43
 [10] top-level scope
    @ ~/MIT_VSCode/SparseRooflineBenchmark/src/output_checker.jl:16
in expression starting at /Users/albertlu00/MIT_VSCode/SparseRooflineBenchmark/src/output_checker.jl:16

code:

using Finch
using NPZ
using TensorMarket
fwrite("test.bspnpy", Tensor(Dense(Element(0.0)), rand(4)))
test = fread("test.bspnpy")
willow-ahrens commented 4 months ago

Hi @albertlu03, It looks like there was a quick fix, so you should be good to continue with the latest changes. Also, congrats on filing the 500th issue! 🎉

I'll ping you when we have a patched finch release all ready