-
Notifications
You must be signed in to change notification settings - Fork 13
Add support for set_cost action to have row level costs for extraction
#343
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
Conversation
This re-implements the syntactic macro in the egglog experimental to create a new table for each function to store its cost. It re-uses the custom extractor which looks up in this table. I talked to @yihongz and we discussed different ways to implement this, from changing syntactic macros to take Expr instead of Sexpr, but settled on just having me re-implement the syntax.
|
@actions-user changelog |
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.
Pull Request Overview
This PR adds support for the set_cost action to enable row-level costs for extraction, implementing functionality similar to the egglog experimental feature. The implementation creates individual cost tables for each function and integrates with a custom extractor that looks up costs from these tables.
Key changes:
- Added
set_costaction to set custom costs for specific expressions - Implemented cost table creation and management for functions with custom costs
- Updated extraction logic to use custom extraction when cost tables are present
Reviewed Changes
Copilot reviewed 8 out of 9 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| python/tests/test_high_level.py | Adds comprehensive test for dynamic cost functionality with expression costs and extraction validation |
| python/egglog/pretty.py | Updates pretty printing to handle SetCostDecl and adds support for displaying cost functions |
| python/egglog/examples/jointree.py | Provides example usage of set_cost in a join tree optimization scenario |
| python/egglog/egraph_state.py | Implements core cost table management, creation logic, and cost callable tracking |
| python/egglog/egraph.py | Adds set_cost function and modifies extraction to use custom extraction when cost tables exist |
| python/egglog/declarations.py | Defines SetCostDecl data structure for representing cost setting actions |
| docs/reference/egglog-translation.md | Documents the new set_cost feature with usage examples and implementation notes |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
Co-authored-by: Copilot <[email protected]>
CodSpeed Instrumentation Performance ReportMerging #343 will not alter performanceComparing Summary
Footnotes |
This re-implements the syntactic macro in the egglog experimental to create a new table for each function to store its cost. It re-uses the custom extractor which looks up in this table.
I talked to @yihongz and we discussed different ways to implement this, from changing syntactic macros to take Expr instead of Sexpr, but settled on just having me re-implement the syntax.
Closes #332