-
Notifications
You must be signed in to change notification settings - Fork 114
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
Optimize arguments
function by removing sorting
#615
Optimize arguments
function by removing sorting
#615
Conversation
Benchmark Results
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
e90b702
to
678bce8
Compare
because the order of arguments is not sorted in the construction step leading to unpredictable output https://github.com/JuliaSymbolics/SymbolicUtils.jl/blob/43797eb43b33b8d6b0374eac8cd6f87f94bcf79d/src/polyform.jl#L106
4ea0338
to
0f56a04
Compare
0f56a04
to
7b2c945
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The MTK failure looks real. Could you check if latex ouput has been properly sorted?
Thanks. |
src/inspect.jl
Outdated
function AbstractTrees.children(x::Symbolic) | ||
iscall(x) ? arguments(x) : isexpr(x) ? children(x) : () | ||
iscall(x) ? arguments(x; sort = true) : isexpr(x) ? children(x) : () |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Shouldn't this not force sort then, given that would be sorted_children
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which option do you prefer?
- Adding a
sort
keyword argument. - Creating new functions
sorted_arguments
andsorted_children
.
Also, the arguments
and children
functions in SymbolicUtils.jl v2.0.2 aren't related to TermInterface.jl yet.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's get the TermInterface.jl change in and hit that interface. Since that's happening like tomorrow there's no need to do a separate version as well.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Which option do you prefer?
1. Adding a `sort` keyword argument. 2. Creating new functions `sorted_arguments` and `sorted_children`.
Also, the
arguments
andchildren
functions in SymbolicUtils.jl v2.0.2 aren't related to TermInterface.jl yet.
@bowenszhu TermInterface.jl 2.0 was merged with sorted_argument
and sorted_children
. I have a PR open for TermInterface.jl 1.0, which should be updated to 2.0 - want update this MR to target that branch? I'll be at a conference and won't have much time.
This should bump to TermInterface v2? |
@ChrisRackauckas there's already #609 (comment) open - which is most of the work. Diff between TI 1.0 and 2.0 is just introduction to |
This pull request is separate from TermInferface. We could integrate this with TermInferface in a future PR. |
Interestingly, the downstream tests say this is pretty breaking. |
This SymbolicUtils.jl pull request removed the function |
Just add it back and have it forward to |
14052d7
to
125506f
Compare
Still some downstream failures |
5050b6d
to
4fda0a8
Compare
2f135ea
to
ae1cbad
Compare
That's duplicating work. I would just update #609 |
It would be amazing if you could target #609 |
…ents-to-unsorted_arguments-to-accelerate-term-traversal
This pull request itself is non-breaking. This pull request introduces changes that result in test failures within the CI, specifically due to deprecation warnings for
|
That PR has breaking updates, this PR is a non-breaking update. So we should merge this and then rebase the other changes on top of this |
The
arguments
function currently sorts the arguments of aBasicSymbolic
expression, which is expensive and often unnecessary. This change removes the unnecessary sorting, resulting in improved performance and reduced memory usage.Sorting arguments remains for printing and
Expr
generation.A test case is skipped because the arguments is not sorted in the construction step of
PolyForm
which leads to unpredictable printing output.SymbolicUtils.jl/src/polyform.jl
Line 106 in 43797eb