Closed mtsokol closed 5 months ago
I forget what error this is, but we see it a lot in Finch and I'd like to make it more descriptive
When you see a "RewriteError", it just means that an error occurred during rewriting. Usually, another error get's printed after that says what actually went wrong. The second stacktrace in this case is:
Stacktrace:
[1] lt(o::Base.Order.ForwardOrdering, a::Int64, b::Nothing)
@ Base.Order ./ordering.jl:117
[2] lt(o::Base.Order.By{Finch.var"#1822#1825"{Finch.FinchLogic.LogicNode}, Base.Order.ForwardOrdering}, a::Finch.FinchLogic.LogicNode, b::Finch.FinchLogic.LogicNode)
@ Base.Order ./ordering.jl:119
[3] lt
@ ./ordering.jl:125 [inlined]
[4] _sort!(v::Vector{Int64}, ::Base.Sort.InsertionSortAlg, o::Base.Order.Perm{Base.Order.By{Finch.var"#1822#1825"{…}, Base.Order.ForwardOrdering}, SubArray{Finch.FinchLogic.LogicNode, 1, Vector{…}, Tuple{…}, true}}, kw::@NamedTuple{scratch::Nothing, lo::Int64, hi::Int64})
@ Base.Sort ./sort.jl:785
[5] _sort!(v::Vector{Int64}, a::Base.Sort.Small{10, Base.Sort.InsertionSortAlg, Base.Sort.IEEEFloatOptimization{…}}, o::Base.Order.Perm{Base.Order.By{…}, SubArray{…}}, kw::@NamedTuple{scratch::Nothing, lo::Int64, hi::Int64})
@ Base.Sort ./sort.jl:750
[6] _sort!
@ ./sort.jl:697 [inlined]
[7] _sort!
@ ./sort.jl:636 [inlined]
[8] #sort!#28
@ ./sort.jl:1463 [inlined]
[9] sort!
@ ./sort.jl:1456 [inlined]
[10] #_sortperm#33
@ ./sort.jl:1664 [inlined]
[11] _sortperm
@ ./sort.jl:1651 [inlined]
[12] #sortperm#32
@ ./sort.jl:1648 [inlined]
[13] (::Finch.SuitableRep)(ex::Finch.FinchLogic.LogicNode)
@ Finch ~/Projects/Finch.jl/src/interface/compute.jl:233
[14] iterate
@ ./generator.jl:47 [inlined]
[15] _collect(c::SubArray{Finch.FinchLogic.LogicNode, 1, Vector{Finch.FinchLogic.LogicNode}, Tuple{UnitRange{…}}, true}, itr::Base.Generator{SubArray{Finch.FinchLogic.LogicNode, 1, Vector{…}, Tuple{…}, true}, Finch.SuitableRep}, ::Base.EltypeUnknown, isz::Base.HasShape{1})
@ Base ./array.jl:854
[16] collect_similar
@ ./array.jl:763 [inlined]
[17] map(f::Finch.SuitableRep, A::SubArray{Finch.FinchLogic.LogicNode, 1, Vector{Finch.FinchLogic.LogicNode}, Tuple{UnitRange{Int64}}, true})
@ Base ./abstractarray.jl:3285
[18] (::Finch.SuitableRep)(ex::Finch.FinchLogic.LogicNode)
@ Finch ~/Projects/Finch.jl/src/interface/compute.jl:224
[19] suitable_storage(ex::Finch.FinchLogic.LogicNode, bindings::Dict{Finch.FinchLogic.LogicNode, Finch.FinchLogic.LogicNode})
@ Finch ~/Projects/Finch.jl/src/interface/compute.jl:213
[20] macro expansion
@ ~/Projects/Finch.jl/src/interface/compute.jl:205 [inlined]
[21] (::Finch.var"#1819#1820"{Dict{Finch.FinchLogic.LogicNode, Finch.FinchLogic.LogicNode}})(__MATCHES__::Base.ImmutableDict{Symbol, Any})
@ Finch ~/.julia/packages/RewriteTools/ncmWH/src/rule.jl:312
[22] success
@ ~/.julia/packages/RewriteTools/ncmWH/src/rule.jl:148 [inlined]
[23] (::RewriteTools.var"#loop#40"{RewriteTools.var"#success#30"{…}})(term::RewriteTools.LL{Vector{…}}, bindings′::Base.ImmutableDict{Symbol, Any}, matchers′::RewriteTools.LL{Tuple{…}})
@ RewriteTools ~/.julia/packages/RewriteTools/ncmWH/src/matchers.jl:96
[24] (::RewriteTools.var"#38#41"{RewriteTools.LL{Vector{…}}, RewriteTools.LL{Tuple{…}}})(b::Base.ImmutableDict{Symbol, Any}, n::Int64)
@ RewriteTools ~/.julia/packages/RewriteTools/ncmWH/src/matchers.jl:101
[25] (::RewriteTools.var"#slot_matcher#36"{RewriteTools.Slot{…}})(next::RewriteTools.var"#38#41"{RewriteTools.LL{…}, RewriteTools.LL{…}}, data::RewriteTools.LL{Vector{…}}, bindings::Base.ImmutableDict{Symbol, Any})
@ RewriteTools ~/.julia/packages/RewriteTools/ncmWH/src/matchers.jl:0
[26] (::RewriteTools.var"#loop#40"{RewriteTools.var"#success#30"{…}})(term::RewriteTools.LL{Vector{…}}, bindings′::Base.ImmutableDict{Symbol, Any}, matchers′::RewriteTools.LL{Tuple{…}})
@ RewriteTools ~/.julia/packages/RewriteTools/ncmWH/src/matchers.jl:100
--- the last 3 lines are repeated 1 more time ---
[30] (::RewriteTools.var"#38#41"{Finch.FinchLogic.LogicNode, Tuple{RewriteTools.var"#literal_matcher#35"{…}, RewriteTools.var"#slot_matcher#36"{…}, RewriteTools.var"#slot_matcher#36"{…}}})(b::Base.ImmutableDict{Symbol, Any}, n::Int64)
@ RewriteTools ~/.julia/packages/RewriteTools/ncmWH/src/matchers.jl:101
[31] literal_matcher
@ ~/.julia/packages/RewriteTools/ncmWH/src/matchers.jl:10 [inlined]
[32] (::RewriteTools.var"#loop#40"{…})(term::Finch.FinchLogic.LogicNode, bindings′::Base.ImmutableDict{…}, matchers′::Tuple{…})
@ RewriteTools ~/.julia/packages/RewriteTools/ncmWH/src/matchers.jl:100
[33] (::RewriteTools.var"#term_matcher#39"{Tuple{…}})(success::RewriteTools.var"#success#30"{Finch.var"#1819#1820"{…}}, data::Tuple{Finch.FinchLogic.LogicNode}, bindings::Base.ImmutableDict{Symbol, Any})
@ RewriteTools ~/.julia/packages/RewriteTools/ncmWH/src/matchers.jl:105
[34] (::RewriteTools.Rule{RewriteTools.Term, RewriteTools.var"#term_matcher#39"{Tuple{…}}, Finch.var"#1819#1820"{Dict{…}}})(term::Finch.FinchLogic.LogicNode)
@ RewriteTools ~/.julia/packages/RewriteTools/ncmWH/src/rule.jl:149
[35] (::RewriteTools.Rewriters.Postwalk{RewriteTools.Rule{RewriteTools.Term, RewriteTools.var"#term_matcher#39"{Tuple{…}}, Finch.var"#1819#1820"{Dict{…}}}})(x::Finch.FinchLogic.LogicNode)
@ RewriteTools.Rewriters ~/.julia/packages/RewriteTools/ncmWH/src/rewriters.jl:122
[36] iterate
@ ./generator.jl:47 [inlined]
[37] collect_to!(dest::Vector{Nothing}, itr::Base.Generator{Vector{Finch.FinchLogic.LogicNode}, RewriteTools.Rewriters.Postwalk{RewriteTools.Rule{RewriteTools.Term, RewriteTools.var"#term_matcher#39"{Tuple{…}}, Finch.var"#1819#1820"{Dict{…}}}}}, offs::Int64, st::Int64)
@ Base ./array.jl:892
[38] collect_to_with_first!(dest::Vector{Nothing}, v1::Nothing, itr::Base.Generator{Vector{Finch.FinchLogic.LogicNode}, RewriteTools.Rewriters.Postwalk{RewriteTools.Rule{RewriteTools.Term, RewriteTools.var"#term_matcher#39"{…}, Finch.var"#1819#1820"{…}}}}, st::Int64)
@ Base ./array.jl:870
[39] _collect(c::Vector{Finch.FinchLogic.LogicNode}, itr::Base.Generator{Vector{Finch.FinchLogic.LogicNode}, RewriteTools.Rewriters.Postwalk{RewriteTools.Rule{…}}}, ::Base.EltypeUnknown, isz::Base.HasShape{1})
@ Base ./array.jl:864
[40] collect_similar(cont::Vector{Finch.FinchLogic.LogicNode}, itr::Base.Generator{Vector{Finch.FinchLogic.LogicNode}, RewriteTools.Rewriters.Postwalk{RewriteTools.Rule{RewriteTools.Term, RewriteTools.var"#term_matcher#39"{Tuple{…}}, Finch.var"#1819#1820"{Dict{…}}}}})
@ Base ./array.jl:763
[41] map(f::RewriteTools.Rewriters.Postwalk{RewriteTools.Rule{RewriteTools.Term, RewriteTools.var"#term_matcher#39"{Tuple{…}}, Finch.var"#1819#1820"{Dict{…}}}}, A::Vector{Finch.FinchLogic.LogicNode})
@ Base ./abstractarray.jl:3285
[42] (::RewriteTools.Rewriters.Postwalk{RewriteTools.Rule{RewriteTools.Term, RewriteTools.var"#term_matcher#39"{Tuple{…}}, Finch.var"#1819#1820"{Dict{…}}}})(x::Finch.FinchLogic.LogicNode)
@ RewriteTools.Rewriters ~/.julia/packages/RewriteTools/ncmWH/src/rewriters.jl:120
[43] (::RewriteTools.Rewriters.Rewrite)(x::Finch.FinchLogic.LogicNode)
@ RewriteTools.Rewriters ~/.julia/packages/RewriteTools/ncmWH/src/rewriters.jl:38
[44] compute_impl(args::Tuple{Finch.LazyTensor{Any, 3}}, ctx::Finch.DefaultOptimizer)
@ Finch ~/Projects/Finch.jl/src/interface/compute.jl:393
[45] compute(args::Tuple{Finch.LazyTensor{Any, 3}}; ctx::Finch.DefaultOptimizer)
@ Finch ~/Projects/Finch.jl/src/interface/compute.jl:369
[46] compute(arg::Finch.LazyTensor{Any, 3}; kwargs::@Kwargs{})
@ Finch ~/Projects/Finch.jl/src/interface/compute.jl:368
[47] compute
@ ~/Projects/Finch.jl/src/interface/compute.jl:368 [inlined]
[48] copy
@ ~/Projects/Finch.jl/src/interface/eager.jl:30 [inlined]
[49] materialize
@ ~/Projects/Finch.jl/src/interface/eager.jl:22 [inlined]
[50] map
@ ~/Projects/Finch.jl/src/interface/eager.jl:44 [inlined]
[51] +(::Tensor{DenseLevel{Int64, DenseLevel{Int64, DenseLevel{Int64, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}}, ::Tensor{DenseLevel{Int64, DenseLevel{Int64, DenseLevel{Int64, ElementLevel{0.0, Float64, Int64, Vector{Float64}}}}}})
@ Finch ~/Projects/Finch.jl/src/interface/eager.jl:76
Some type information was truncated. Use `show(err)` to see complete types.
In this case, it looks like we were trying to sort indices based on where they occur in a reorder statement, but one of them did not occur in the statement. Usually this means that we dropped some dimensions, but we aren't supposed to drop dims here.
The dims are (1, 10, 10)
. I guess singleton 1
got dropped somewhere?
Yes, I don't think we're really supposed to drop here
I think I have a fix up and running
Hi @willow-ahrens!
While trying to run some benchmarks I came across such issue:
Code for bug repro:
Error log: