-
-
Notifications
You must be signed in to change notification settings - Fork 211
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
Build function allocating on large expressions? #551
Comments
This is an instance of JuliaLang/julia#34999 . @shashi @YingboMa do we have a cheap way to break down big |
We can walk the tree and cut it up in using SymbolicUtils
function nest_long_plus(x, N)
x = to_symbolic(x)
rule = @rule (+(~~x) => length(~~x) > N ? +(+((~~x)[1:N]...) + +((~~x)[N+1:end]...))
Rewrtiters.Fixpoint(Rewriters.Chain([rule]))(x) |> to_mtk
end |
That could work. Is there no easy way to do this at trace time, like by defining |
I think in this case it did get built recursively but simplify flattened it, it's useful to flatten for simplification (e.g. cancellations are easy). |
I see, so yeah then we should cut it up in |
This problem comes up in large complex networks:
For
N=10
everything works as expected: the MTK version is 4x faster and does not allocate.The text was updated successfully, but these errors were encountered: