Closed CarloLucibello closed 10 months ago
On master does Float32.(x)
not work?
Float32.(x)
works on 0.9 indeed. The other attempts fail differently now
julia> x = GBMatrix([1,2], [2, 3], [1,2], fill=0)
2x3 GraphBLAS int64_t matrix, bitmap by row
2 entries, memory: 264 bytes
(1,2) 1
(2,3) 2
julia> Float32.(x)
2x3 GraphBLAS float matrix, bitmap by row
2 entries, memory: 238 bytes
(1,2) 1
(2,3) 2
julia> map(Float32, x)
ERROR: "Unsupported function SuiteSparseGraphBLAS.var\"#unaryopfn#10\"{DataType}. Closure functions are not supported."
Stacktrace:
[1] #s77#9
@ ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/types.jl:38 [inlined]
[2] var"#s77#9"(F::Any, X::Any, Z::Any, ::Any, f::Any, #unused#::Type, #unused#::Any)
@ SuiteSparseGraphBLAS ./none:0
[3] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any})
@ Core ./boot.jl:582
[4] unsafe_convert(#unused#::Type{Ptr{SuiteSparseGraphBLAS.LibGraphBLAS.GB_UnaryOp_opaque}}, op::SuiteSparseGraphBLAS.TypedUnaryOperator{DataType, Int64, Float32})
@ SuiteSparseGraphBLAS ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/types.jl:56
[5] GrB_Matrix_apply(C::GBMatrix{Float32, Float32}, Mask::Ptr{Nothing}, accum::Ptr{Nothing}, op::SuiteSparseGraphBLAS.TypedUnaryOperator{DataType, Int64, Float32}, A::GBMatrix{Int64, Int64}, desc::Descriptor)
@ SuiteSparseGraphBLAS.LibGraphBLAS ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/lib/LibGraphBLAS_gen.jl:1284
[6] apply!(op::Type, C::GBMatrix{Float32, Float32}, A::GBMatrix{Int64, Int64}; mask::Nothing, accum::Nothing, desc::Nothing)
@ SuiteSparseGraphBLAS ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/operations/map.jl:10
[7] apply(op::Type, A::GBMatrix{Int64, Int64}; mask::Nothing, accum::Nothing, desc::Nothing)
@ SuiteSparseGraphBLAS ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/operations/map.jl:49
[8] #map#502
@ ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/operations/map.jl:109 [inlined]
[9] map(f::Type, A::GBMatrix{Int64, Int64})
@ SuiteSparseGraphBLAS ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/operations/map.jl:108
[10] top-level scope
@ REPL[21]:1
julia> convert(GBMatrix{Float32}, x)
ERROR: Abstract type Any does not have a definite size.
Stacktrace:
[1] sizeof(x::Type)
@ Base ./essentials.jl:473
[2] _sizedjlmalloc(n::Int64, #unused#::Type{Any})
@ SuiteSparseGraphBLAS ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/mem.jl:14
[3] convert(::Type{GBMatrix{Float32}}, A::GBMatrix{Int64, Int64}; fill::Int64)
@ SuiteSparseGraphBLAS ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/convert.jl:14
[4] convert(::Type{GBMatrix{Float32}}, A::GBMatrix{Int64, Int64})
@ SuiteSparseGraphBLAS ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/convert.jl:7
[5] top-level scope
@ REPL[22]:1
julia> convert(GBMatrix{Float32, Float32}, x)
ERROR: SuiteSparseGraphBLAS.NullPointerError
Stacktrace:
[1] _packhypermatrix!(A::GBMatrix{Int64, Int64}, ptr::Vector{Int64}, idx1::Vector{Int64}, idx2::Vector{Int64}, values::Vector{Int64}; desc::Nothing, order::RowMajor, decrementindices::Bool, jumbled::Bool)
@ SuiteSparseGraphBLAS ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/pack.jl:187
[2] #unsafepack!#341
@ ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/pack.jl:250 [inlined]
[3] repack!
@ ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/unpack.jl:509 [inlined]
[4] repack! (repeats 6 times)
@ ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/unpack.jl:507 [inlined]
[5] convert(::Type{GBMatrix{Float32, Float32}}, A::GBMatrix{Int64, Int64}; fill::Int64)
@ SuiteSparseGraphBLAS ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/convert.jl:17
[6] convert(::Type{GBMatrix{Float32, Float32}}, A::GBMatrix{Int64, Int64})
@ SuiteSparseGraphBLAS ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/convert.jl:7
[7] top-level scope
@ REPL[23]:1
I'll leave the issue open since all of these should work ideally
Another error when composing broadcasts:
julia> x = GBMatrix([1,2], [2, 3], [1,2])
2x3 GraphBLAS int64_t matrix, bitmap by row
2 entries, memory: 264 bytes
(1,2) 1
(2,3) 2
julia> b = x .> 0
2x3 GraphBLAS bool matrix, bitmap by row
2 entries, memory: 224 bytes
(1,2) 1
(2,3) 1
julia> Float32.(b)
2x3 GraphBLAS float matrix, bitmap by row
2 entries, memory: 238 bytes
(1,2) 1
(2,3) 1
julia> Float32.(x .> 0)
ERROR: "Unsupported function SuiteSparseGraphBLAS.var\"#unaryopfn#10\"{DataType}. Closure functions are not supported."
Stacktrace:
[1] #s77#9
@ ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/types.jl:38 [inlined]
[2] var"#s77#9"(F::Any, X::Any, Z::Any, ::Any, f::Any, #unused#::Type, #unused#::Any)
@ SuiteSparseGraphBLAS ./none:0
[3] (::Core.GeneratedFunctionStub)(::Any, ::Vararg{Any})
@ Core ./boot.jl:582
[4] unsafe_convert(#unused#::Type{Ptr{SuiteSparseGraphBLAS.LibGraphBLAS.GB_UnaryOp_opaque}}, op::SuiteSparseGraphBLAS.TypedUnaryOperator{DataType, Bool, Float32})
@ SuiteSparseGraphBLAS ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/types.jl:56
[5] GrB_Matrix_apply(C::GBMatrix{Float32, Float32}, Mask::Ptr{Nothing}, accum::Ptr{Nothing}, op::SuiteSparseGraphBLAS.TypedUnaryOperator{DataType, Bool, Float32}, A::GBMatrix{Bool, Bool}, desc::Descriptor)
@ SuiteSparseGraphBLAS.LibGraphBLAS ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/lib/LibGraphBLAS_gen.jl:1284
[6] apply!(op::Type, C::GBMatrix{Float32, Float32}, A::GBMatrix{Bool, Bool}; mask::Nothing, accum::Nothing, desc::Nothing)
@ SuiteSparseGraphBLAS ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/operations/map.jl:10
[7] #apply#495
@ ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/operations/map.jl:49 [inlined]
[8] apply
@ ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/operations/map.jl:44 [inlined]
[9] copy
@ ~/.julia/packages/SuiteSparseGraphBLAS/hotIr/src/operations/broadcasts.jl:79 [inlined]
[10] materialize(bc::Base.Broadcast.Broadcasted{SuiteSparseGraphBLAS.GBMatrixStyle, Nothing, Type{Float32}, Tuple{Base.Broadcast.Broadcasted{SuiteSparseGraphBLAS.GBMatrixStyle, Nothing, typeof(>), Tuple{GBMatrix{Int64, Int64}, Int64}}}})
@ Base.Broadcast ./broadcast.jl:860
[11] top-level scope
@ REPL[79]:1
Fixed in v0.10 as far as I can tell (please re-open if this is platform specific. It might be since closure cfunctions aren't supported on macOS ARM I believe).
I couldn't find a way to convert an integer valued
GBMatrix
to a float one: