Closed yakir12 closed 5 years ago
I have the same issue and it even happens for two of the examples in the readme.md.
julia> function naive_sum(xs)
s = 0
for x in xs
s += x
end
return s
end
naive_sum (generic function with 1 method)
julia> @trace naive_sum([1.])
ERROR: no unique matching method found for the specified argument types
and
julia> y=1
1
julia> f(x) = x+y
f (generic function with 1 method)
julia> @trace f(1.0)
ERROR: no unique matching method found for the specified argument types
The stacktrace looks the same as yours. Interestingly the naive_relu example is working as expected.
Can you try Traceur#master
? I can't seem to repro this issue with either of the above examples and Julia 1.0.3.
Will release a new version if you can confirm.
Both @kurbkid's examples from the readme worked for me (after switching to master), but my own example didn't:
julia> distance(orig, dir, pos)
0.5
julia> @trace distance(orig, dir, pos)
ERROR: ArgumentError: argument is not a generic function
Stacktrace:
[1] which(::Any, ::Any) at ./reflection.jl:920
[2] method(::Traceur.DynamicCall{typeof(tuple),Tuple{Int64}}) at /home/yakir/.julia/packages/Traceur/LWoeA/src/analysis.jl:21
[3] posthook(::Cassette.Context{nametype(TraceurCtx),Traceur.Trace,Nothing,getfield(Cassette, Symbol("##PassType#363")),Nothing,Nothing}, ::Function, ::Tuple{Int64}, ::Int64) at /home/yakir/.julia/packages/Traceur/LWoeA/src/trace.jl:29
[4] Type at /home/yakir/.julia/packages/StaticArrays/mcf7t/src/traits.jl:67 [inlined]
[5] overdub(::Cassette.Context{nametype(TraceurCtx),Traceur.Trace,Nothing,getfield(Cassette, Symbol("##PassType#363")),Nothing,Nothing}, ::Type{Size}, ::Type{Tuple{3}}) at /home/yakir/.julia/packages/Cassette/LvKdG/src/overdub.jl:0
[6] Type at /home/yakir/.julia/packages/StaticArrays/mcf7t/src/traits.jl:88 [inlined]
[7] overdub(::Cassette.Context{nametype(TraceurCtx),Traceur.Trace,Nothing,getfield(Cassette, Symbol("##PassType#363")),Nothing,Nothing}, ::Type{Size}, ::Type{SArray{Tuple{3},Float64,1,3}}) at /home/yakir/.julia/packages/Cassette/LvKdG/src/overdub.jl:0
[8] Type at /home/yakir/.julia/packages/StaticArrays/mcf7t/src/traits.jl:86 [inlined]
[9] overdub(::Cassette.Context{nametype(TraceurCtx),Traceur.Trace,Nothing,getfield(Cassette, Symbol("##PassType#363")),Nothing,Nothing}, ::Type{Size}, ::SArray{Tuple{3},Float64,1,3}) at /home/yakir/.julia/packages/Cassette/LvKdG/src/overdub.jl:0
[10] same_size at /home/yakir/.julia/packages/StaticArrays/mcf7t/src/traits.jl:193 [inlined]
[11] map at /home/yakir/.julia/packages/StaticArrays/mcf7t/src/mapreduce.jl:11 [inlined]
[12] - at /home/yakir/.julia/packages/StaticArrays/mcf7t/src/linalg.jl:6 [inlined]
[13] distance at ./REPL[4]:2 [inlined]
[14] overdub(::Cassette.Context{nametype(TraceurCtx),Traceur.Trace,Nothing,getfield(Cassette, Symbol("##PassType#363")),Nothing,Nothing}, ::typeof(distance), ::SArray{Tuple{3},Float64,1,3}, ::SArray{Tuple{3},Float64,1,3}, ::Bool) at /home/yakir/.julia/packages/Cassette/LvKdG/src/overdub.jl:0
[15] #7 at /home/yakir/.julia/packages/Traceur/LWoeA/src/trace.jl:49 [inlined]
[16] recurse(::Cassette.Context{nametype(TraceurCtx),Traceur.Trace,Nothing,getfield(Cassette, Symbol("##PassType#363")),Nothing,Nothing}, ::getfield(Main, Symbol("##7#8"))) at /home/yakir/.julia/packages/Cassette/LvKdG/src/overdub.jl:0
[17] trace(::Function, ::Function) at /home/yakir/.julia/packages/Traceur/LWoeA/src/trace.jl:38
[18] warntrace(::Function) at /home/yakir/.julia/packages/Traceur/LWoeA/src/trace.jl:40
[19] top-level scope at none:0
The examples work for me on master too. Btw, is it normal that it takes a minute?
Hm, @yakir12's example works fine for me as well:
julia> distance(orig, dir, pos)
0.5
julia> @trace distance(orig, dir, pos)
0.5
Btw, is it normal that it takes a minute?
The naive_sum
example takes about 10s for me, but yeah, the current approach will be quite slow due to lots of recompilation happening. Once https://github.com/JuliaDebug/ASTInterpreter2.jl/pull/37 is ironed out and a new release is tagged I'll probably port Traceur back to that instead of using Cassette, which should improve performance drastically.
@yakir12's example works fine for me as well:
Whaaat... So what should I try..?
Ah, I did have an unrelated change dev
ed that caused the error to not appear. This seems like an upstream bug to me (see https://github.com/jrevels/Cassette.jl/issues/101), but I've pushed a commit that should fix it anyways.
So yeah, please try latest master and if it works for you I'll tag a new release.
It worked (with warnings)!
julia> @trace distance(orig, dir, pos)
┌ Warning: dynamic dispatch to ((Core.apply_type)(StaticArrays.Size, (Core._apply)(StaticArrays.tuple, (Base.getfield)(s, parameters))))()
└ @ ~/.julia/packages/StaticArrays/mcf7t/src/traits.jl:67
┌ Warning: dynamic dispatch to ((Core.apply_type)(StaticArrays.Size, s))()
└ @ ~/.julia/packages/StaticArrays/mcf7t/src/traits.jl:65
0.5
Alright, cool. I think those warnings are false positives, but that's kinda expected. Will release a new version for now.
I have a fairly straightforward piece of code (calculates the shortest distance to a dome according to some criterion):
I wanted to test it but I get this error: