-
Notifications
You must be signed in to change notification settings - Fork 8
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
@rewrite for arbitrary operation/function #253
Comments
Specifically, there is no speedup nor reduction in the memory allocation for evaluation of say t = @rewrite sin(x*sin(y)) + sin(z) |
Correct the |
Would it be a lot of work to generalize this macro for any overloaded function? It looks like other parts of the interface can handle arbitrary functions (seeing |
The macro is defined here (x-ref #254): MutableArithmetics.jl/src/rewrite.jl Lines 7 to 29 in 0b3f7d1
It isn't very complicated. Here's the actual rewrites: MutableArithmetics.jl/src/rewrite_generic.jl Lines 58 to 218 in 0b3f7d1
I don't know if we want to add a generalized rewrite. The main purpose of MutableArithmetics is for JuMP. @blegat is the one who would need to decide. |
Thanks. Worst case I suppose I could import and modify it. The use case is for GTPSA.jl, a package wrapping a C library for manipulating truncated power series. Each mutable struct is a truncated power series and all the Base math functions are overloaded. Currently all the intermediate values in an expression allocate a new struct. Preliminary testing with using a preallocated temporary buffer shows quite a big speedup. So using a macro or some other method that could do this would be very advantageous |
I'm not opposed to adding support for these unary functions. PR welcome |
We'd just need to be very careful to ensure that the new rewrite doesn't break JuMP's nonlinear code. |
Does MutableArithmetics not work for general functions, only for the standard arithmetic operations (+,-,/,*)? I have a mutable type that overrides many of the Base functions (sin, cos, abs, sqrt, csc) as well as some others not in base (sinhc). I'd really like to use this interface and the
@rewrite
macro to speed up evaluation of expressions, but I've found it doesn't work for these functions.My code for sin for example is
The text was updated successfully, but these errors were encountered: