Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

iterate(::typeof(copyto!)) #126

Open
maartenvd opened this issue Jul 8, 2024 · 3 comments · May be fixed by #127
Open

iterate(::typeof(copyto!)) #126

maartenvd opened this issue Jul 8, 2024 · 3 comments · May be fixed by #127

Comments

@maartenvd
Copy link

Trying @dynamo to "highjack" all calls to a certain previously defined methods. I seem to run into issues when combining with broadcasting:


using IRTools: IR, @dynamo, recurse!
@dynamo function quicktest(a...)
    ir = IR(a...)
    isnothing(ir) && return
    recurse!(ir)
    return ir
end


quicktest() do
  a = rand(5);
  reduce(&, a .== a)
end

fails on 1.10.4 with


ERROR: MethodError: no method matching iterate(::typeof(copyto!))

Closest candidates are:
  iterate(::Pkg.Types.Manifest, ::Int64)
   @ Pkg ~/julia/usr/share/julia/stdlib/v1.10/Pkg/src/Types.jl:314
  iterate(::Pkg.Types.Manifest)
   @ Pkg ~/julia/usr/share/julia/stdlib/v1.10/Pkg/src/Types.jl:313
  iterate(::Combinatorics.IntegerPartitions)
   @ Combinatorics ~/.julia/packages/Combinatorics/Udg6X/src/partitions.jl:20
  ...

Stacktrace:
  [1] macro expansion
    @ ~/.julia/packages/IRTools/ntYVg/src/reflection/dynamo.jl:0 [inlined]
  [2] quicktest(::typeof(iterate), ::typeof(copyto!))
    @ Main ~/.julia/packages/IRTools/ntYVg/src/reflection/dynamo.jl:177
  [3] _foldl_impl
    @ ./reduce.jl:56 [inlined]
  [4] quicktest(::typeof(Base._foldl_impl), ::Base.BottomRF{typeof(&)}, ::Base._InitialValue, ::typeof(copyto!))
    @ Main ~/.julia/packages/IRTools/ntYVg/src/reflection/dynamo.jl:0
  [5] foldl_impl
    @ ./reduce.jl:48 [inlined]
  [6] quicktest(::typeof(Base.foldl_impl), ::Base.BottomRF{typeof(&)}, ::Base._InitialValue, ::typeof(copyto!))
    @ Main ~/.julia/packages/IRTools/ntYVg/src/reflection/dynamo.jl:0
  [7] mapfoldl_impl
    @ ./reduce.jl:44 [inlined]
  [8] quicktest(::typeof(Base.mapfoldl_impl), ::typeof(identity), ::typeof(&), ::Base._InitialValue, ::typeof(copyto!))
    @ Main ~/.julia/packages/IRTools/ntYVg/src/reflection/dynamo.jl:0
  [9] #mapfoldl#298
    @ ./reduce.jl:175 [inlined]
 [10] 
    @ Main ~/.julia/packages/IRTools/ntYVg/src/reflection/dynamo.jl:0
 [11] mapfoldl
    @ ./reduce.jl:175 [inlined]
 [12] quicktest(::typeof(mapfoldl), ::typeof(identity), ::typeof(&), ::typeof(copyto!))
    @ Main ~/.julia/packages/IRTools/ntYVg/src/reflection/dynamo.jl:0
 [13] #mapreduce#302
    @ ./reduce.jl:307 [inlined]
 [14] quicktest(::Base.var"##mapreduce#302", ::@Kwargs{}, ::typeof(mapreduce), ::typeof(identity), ::typeof(&), ::typeof(copyto!))
    @ Main ~/.julia/packages/IRTools/ntYVg/src/reflection/dynamo.jl:0
 [15] mapreduce
    @ ./reduce.jl:307 [inlined]
 [16] quicktest(::typeof(mapreduce), ::typeof(identity), ::typeof(&), ::typeof(copyto!))
    @ Main ~/.julia/packages/IRTools/ntYVg/src/reflection/dynamo.jl:0
 [17] #reduce#304
    @ ./reduce.jl:490 [inlined]
 [18] quicktest(::Base.var"##reduce#304", ::@Kwargs{}, ::typeof(reduce), ::typeof(&), ::typeof(copyto!))
    @ Main ~/.julia/packages/IRTools/ntYVg/src/reflection/dynamo.jl:0
 [19] reduce
    @ ./reduce.jl:490 [inlined]
 [20] quicktest(::typeof(reduce), ::typeof(&), ::typeof(copyto!))
    @ Main ~/.julia/packages/IRTools/ntYVg/src/reflection/dynamo.jl:0
 [21] #10
    @ ~/projects/MPSKitExperimental.jl/examples/qchem.jl:157 [inlined]
 [22] quicktest(args::var"#10#11")
    @ Main ~/.julia/packages/IRTools/ntYVg/src/reflection/dynamo.jl:0
 [23] top-level scope
    @ ~/projects/MPSKitExperimental.jl/examples/qchem.jl:155
Some type information was truncated. Use `show(err)` to see complete types.
@maartenvd
Copy link
Author

Also, if recurse!(::Nothing) was defined, couldn't the dynamo example be even prettier:

@dynamo function quicktest(a...)
    ir = IR(a...)
    recurse!(ir)
    return ir
end

@oxinabox
Copy link
Member

TBH @dynamo is largely unmaintained as it isn't used by Zygote, and keeping Zygote working is main thing that prompts PRs against this repo

@maartenvd
Copy link
Author

That is sad, is there a maintained alternative? I tried cassette but run into the llvmcall issue, cassetteoverlay runs into different issues still. At some point there ways mixtape, but that seems discontinued too

What is working, but is far too slow, is overloading juliainterpreters framedict

@maartenvd maartenvd linked a pull request Jul 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants