-
Notifications
You must be signed in to change notification settings - Fork 9
Refactor optimization pipeline. #520
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
Merged
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
fab7871
refactor(optimize): generalize OptRes::flops → ops and extract DP hel…
bimalgaudel 2dc64d3
feature(memsize_counter): new metric that computes binary tensor cont…
bimalgaudel c8f8914
refactor(optimize): make cost metric and index extent provider config…
bimalgaudel 0efc42b
refactor(optimize): consolidate public knobs into OptimizeOptions
bimalgaudel 59f4b57
refactor(optimize): re-add bool backwards-compat overloads and docume…
bimalgaudel f667916
Add the deprecation attributes the relevant functions.
bimalgaudel a1d0264
test(optimize): cover OptimizeOptions, Memsize metric, and parallel s…
evaleev File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| #ifndef SEQUANT_CORE_OPTIMIZE_OPTIONS_HPP | ||
| #define SEQUANT_CORE_OPTIMIZE_OPTIONS_HPP | ||
|
|
||
| #include <cstddef> | ||
| #include <functional> | ||
|
|
||
| namespace sequant { | ||
|
|
||
| class Index; | ||
|
|
||
| /// Cost metric to optimize for in single-term and top-level optimize routines. | ||
| enum class OptFor { Flops, Memsize }; | ||
|
|
||
| /// Whether to reorder summands so terms with shared intermediates appear | ||
| /// closer to each other. | ||
| enum class ReorderSum { Reorder, NoReorder }; | ||
|
|
||
| /// A type-erased provider mapping an Index to its extent. Used by the public | ||
| /// optimize() API. Callers reaching for the templated opt::single_term_opt | ||
| /// overloads (constrained by \ref opt::has_index_extent) should pass the | ||
| /// callable directly instead of wrapping it here — that keeps the cost | ||
| /// function's call site inlineable, whereas a value of this alias goes | ||
| /// through std::function's type-erased dispatch on every Index lookup. | ||
| using index_to_extent_t = std::function<std::size_t(Index const&)>; | ||
|
|
||
| /// Options that control behavior of \ref sequant::optimize. | ||
| struct OptimizeOptions { | ||
| /// Cost metric to minimize. | ||
| OptFor opt_for = OptFor::Flops; | ||
|
|
||
| /// Whether to reorder summands so terms with shared intermediates appear | ||
| /// closer to each other. | ||
| ReorderSum reorder = ReorderSum::Reorder; | ||
|
|
||
| /// Caller-supplied Index to extent provider. If empty, defaults to | ||
| /// \c IndexSpace::approximate_size(). | ||
| index_to_extent_t idx_to_extent = {}; | ||
| }; | ||
|
|
||
| } // namespace sequant | ||
|
|
||
| #endif // SEQUANT_CORE_OPTIMIZE_OPTIONS_HPP |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
We can (and maybe should) make use of the
[[deprecated]]attribute: https://en.cppreference.com/cpp/language/attributes/deprecatedThere 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.
I thought about that. I might add it.