Optimize evaluation of function, Jacobian, and Hessian using joint CSE #29472
Replies: 2 comments
-
|
Thanks for converting to a discussion. |
Beta Was this translation helpful? Give feedback.
-
|
There is a explanation of such an idea here: https://github.com/sympy/sympy/wiki/GSoC-Ideas#code-generation-efficient-jacobian-and-hessian-evaluation-for-optimization-and-ode-integration |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi,
While experimenting with optimization workflows in SymPy, I noticed something interesting regarding CSE.
If we compute CSE separately on a function, its gradient, and Hessian, some common subexpressions seem to get repeated. But when I apply CSE jointly on all of them together, the number of replacements is lower.
For example:
cse([f, grad, hess]) vs applying cse separately.
This suggests there might be an opportunity to reduce redundant computations, especially for large expressions.
Is this expected behavior, or could this be something worth improving (maybe in codegen or helper utilities)?
Happy to explore this further if it makes sense.
Thanks!
Beta Was this translation helpful? Give feedback.
All reactions