Skip to content
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

Compiled Pattern Matching #204

Merged
merged 8 commits into from
May 8, 2024
Merged

Conversation

0x0f0f0f
Copy link
Member

@0x0f0f0f 0x0f0f0f commented May 8, 2024

Change base to ale/3.0 after tests green

Compile classical rewriting matchers as functions, same style as ematch_compiler.

Basically

julia> r = @rule f(~~x, 3, ~~y, 5, ~~z, 7) => (~~x, ~~y, ~~z)
f(~x..., 3, ~y..., 5, ~z..., 7) => (x, y, z)

julia> @btime  r(:(f(1,2,2,3,4,4,5,6,7,7)))
  472.199 ns (14 allocations: 944 bytes)
(Any[1, 2, 2], Any[4, 4], Any[6, 7])

Compared to SU:

julia> r = SymbolicUtils.@rule f(~~x, 3, ~~y, 5, ~~z, 7) => (~~x, ~~y, ~~z)
       t = term(f, 1, 2, 2, 3, 4, 4, 5, 6, 7, 7)

       @btime r(t)
  2.019 μs (111 allocations: 4.83 KiB)
(Any[1, 2, 2], Any[4, 4], Any[6, 7])

cc @shashi @ChrisRackauckas

@codecov-commenter
Copy link

codecov-commenter commented May 8, 2024

Codecov Report

Attention: Patch coverage is 84.92780% with 167 lines in your changes are missing coverage. Please review.

Project coverage is 74.76%. Comparing base (a8331d6) to head (414bcbc).
Report is 3 commits behind head on master.

Files Patch % Lines
src/EGraphs/egraph.jl 80.88% 43 Missing ⚠️
src/utils.jl 6.25% 30 Missing ⚠️
src/matchers.jl 44.73% 21 Missing ⚠️
src/Patterns.jl 67.39% 15 Missing ⚠️
src/Syntax.jl 86.45% 13 Missing ⚠️
src/EGraphs/saturation.jl 94.48% 8 Missing ⚠️
ext/Plotting.jl 0.00% 6 Missing ⚠️
src/Rewriters.jl 53.84% 6 Missing ⚠️
src/Rules.jl 66.66% 6 Missing ⚠️
src/ematch_compiler.jl 95.83% 6 Missing ⚠️
... and 6 more

❗ Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files
@@            Coverage Diff             @@
##           master     #204      +/-   ##
==========================================
+ Coverage   69.17%   74.76%   +5.58%     
==========================================
  Files          16       20       +4     
  Lines        1353     1581     +228     
==========================================
+ Hits          936     1182     +246     
+ Misses        417      399      -18     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@0x0f0f0f 0x0f0f0f changed the base branch from master to ale/3.0 May 8, 2024 20:51
@0x0f0f0f
Copy link
Member Author

0x0f0f0f commented May 8, 2024

cc @thautwarm - after years, we ended up compiling the patterns. I remember you recommending me not to interpret them!

@0x0f0f0f 0x0f0f0f merged commit 1e2ae88 into ale/3.0 May 8, 2024
4 of 5 checks passed
0x0f0f0f added a commit that referenced this pull request May 10, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants