Conversation
|
Codecov ReportAttention: Patch coverage is
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## ale/3.0 #262 +/- ##
===========================================
+ Coverage 81.42% 82.28% +0.86%
===========================================
Files 19 19
Lines 1491 1547 +56
===========================================
+ Hits 1214 1273 +59
+ Misses 277 274 -3 ☔ View full report in Codecov by Sentry. |
Benchmark Results
Benchmark PlotsA plot of the benchmark results have been uploaded as an artifact to the workflow run for this PR. |
| @inline get_constant(@nospecialize(g::EGraph), hash::UInt64) = g.constants[hash] | ||
| @inline has_constant(@nospecialize(g::EGraph), hash::UInt64)::Bool = haskey(g.constants, hash) | ||
|
|
||
| @inline needs_operation_quoting(g::EGraph) = false |
| @assert isground(p) | ||
| function lookup_pat(g::EGraph{ExpressionType}, p::Pat)::Id where {ExpressionType} | ||
| if p.type === PAT_LITERAL | ||
| # TODO avoid using enode vector for lookup, just try using hash |
There was a problem hiding this comment.
cc @gkronber this is related to how literals are handled in the e-graph. we could probably save some computation time here
There was a problem hiding this comment.
I'm not sure how. We need to return the eclass-id for the literal, and for this we need to find the node in memo and then find the canonical eclass id via UF.
The canonicalization of VecExpr (in lookup()) is not necessary for literal enodes, but probably not too costly.
| function cached_ids(g::EGraph, p::Pat) | ||
| p.type === PAT_VARIABLE && return Iterators.map(x -> x.val, keys(g.classes)) | ||
|
|
||
| if p.isground | ||
| id = lookup_pat(g, p) | ||
| iszero(id) ? UNDEF_ID_VEC : [id] | ||
| id > 0 ? [id] : UNDEF_ID_VEC | ||
| else | ||
| get(g.classes_by_op, IdKey(v_signature(p.n)), UNDEF_ID_VEC) | ||
| end | ||
| end |
| Abstract type representing a pattern used in all the various pattern matching backends. | ||
| """ | ||
| abstract type AbstractPat end | ||
| @enum PatternType PAT_LITERAL PAT_VARIABLE PAT_SEGMENT PAT_EXPR |
|
@gkronber this should remove the runtime dispatch overhead in The only runtime dispatch overhead that should be left is in A well known problem https://discourse.julialang.org/t/struct-with-a-field-of-type-function/49669/5 While Function wrappers may not work, I would be ok with a |
|
|
|
4191320 LGTM |
Found some time to finish an optimization I had lying around. Use an optimized struct for Patterns for type stability of most recursive procedures.