-
Notifications
You must be signed in to change notification settings - Fork 32
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
Type inference and exponentially large compile times #256
Comments
Thank you for the report. Would an implementation of |
Yes would solve the issue with Unfortunately, the problem will still persist for any operation that combines several linear operators together. For example the following: A = opEye(n)
for i=1:N
A = A*LinearOperator(randn(n,n))
end
y = A*randn(n) takes way too long inferring types for say A = LinearOperator(randn(10,10))
B = LinearOperator(randn(10,10))
C = A*B
typeof(C) gives a long type that is not included here because it is not human-readable. BTW, when developing code using As far as I understand, this is a consequence of using |
Yes, this is probably because the parametric type LinearOperators.jl/src/abstract.jl Lines 47 to 63 in a204372
After looking at #97, I see that the fix was to remove the parameters |
I really don't see the benefit of using closures. I do see however that using closures affects performance the first time a Maybe it is good to add warning somewhere in the documentation about this limitation, i.e. operations involving more than 10 operators can be long to compile. In Julia, compilation is also a performance problem... FYI, I just realized that LinearMaps.jl does not have the same problem. The types generated by composite operations are also more humanly readable. Anyway, I have some testing to do to see if it is worth migrating. |
Issue #97 seemed to fix problems with type inference taking an inordinate amount of time when stringing together several
LinearOperator
s. As far as I could tell, issue #97 was fixed, but the problem seems to be back in Julia 1.8.1. Please see below for a minimal working example + output on a fresh session of Julia 1.8.1 (I am usingv2.4.1
). Of course after running this another time in the same Julia session, the type inference is done and the whole thing takes very little time (as it would be expected)Julia takes 46s to do type inference on a
hcat
of 17 operators:The text was updated successfully, but these errors were encountered: