Comments (3)
A workaround for now is to add extra methods to cause specialization, e.g.
f(args...) = # actual code
f(a) = invoke(f, Tuple{Vararg{Any}}, a,)
f(a, b) = invoke(f, Tuple{Vararg{Any}}, a, b)
f(a, b, c) = invoke(f, Tuple{Vararg{Any}}, a, b, c)
...
from cassette.jl.
Thanks, trying this out now. Two questions:
-
How does this workaround interact with inlining? Can things get inlined throughFrom some cursory exploration, it looks likeinvoke
or isinvoke
a de facto inline barrier?invoke
is not an inline barrier. Cassette forcibly inlines a lot of stuff, with the hopes that eventual no-op transformations are elided in generated code (in many use cases, "most" of Cassette's transformations end up being no-ops/pass-throughs). -
It seems that I'm running into a cycle when implementing this workaround for one of Cassette's callable structs. Here's a MWE:
julia> struct Foo{X,F}
x::X
f::F
end
julia> (foo::Foo{Int})(args...) = foo.f(args...)
julia> (foo::Foo{Int})(x) = invoke(foo, Tuple{Vararg{Any}}, x)
julia> Foo(1, sin)(1)
ERROR: StackOverflowError:
Stacktrace:
[1] (::Foo{Int64,typeof(sin)})(::Int64) at ./REPL[3]:0
[2] (::Foo{Int64,typeof(sin)})(::Int64) at ./REPL[3]:1 (repeats 26666 times)
EDIT: Furthermore:
julia> struct Foo{F}
x
f::F
end
julia> (foo::Foo)(args...) = foo.f(args...)
julia> (foo::Foo)(a) = invoke(foo, Tuple{Vararg{Any}}, a)
julia> @code_typed Foo(1, sin)(1)^C
julia> Foo(1, sin)(1)
[1] 52977 segmentation fault julia7
Weirdly, the bug goes away if we get rid of the x
field, but that field is actually necessary in the real code. What should I be doing here instead?
from cassette.jl.
closed by #41
from cassette.jl.
Related Issues (20)
- Inference issues with accessing hcat-ed arrays
- Tag new version HOT 5
- Internal error when overdubbing HTTP.request HOT 1
- Open discussion - support for dynamic pass creation HOT 3
- Overdubbing not working when function called from within `@threads for` loop HOT 2
- Code using Cassette fails for nightly builds HOT 2
- Discriminating overdub calls for "same" function/args HOT 1
- Is there a way to bail out of overdubbing? HOT 2
- TagBot trigger issue HOT 10
- Errors on Julia v1.6 HOT 3
- less helpful stacktraces on 1.6 HOT 3
- Error compiling Cubature.hcubature in context Traceur.Trace
- Default value to `reflect` should be `Base.current_world` HOT 1
- Cassette and AbstractInterpeter
- Cassette compilation fails as of Julia commit 6ce28008ba6db324b171909fa8e641fe8bce9db4 HOT 1
- Error in overdub with StaticArrays.jl HOT 5
- Error on ColorTypes HOT 2
- Very high TTFX HOT 1
- nightly failing to precompile with `ERROR: LoadError: invalid struct allocation` HOT 3
- `Reflection` should probably store the `MethodInstance` and possibly the `world`.
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from cassette.jl.