-
Notifications
You must be signed in to change notification settings - Fork 128
[AIMIGRAPHX-835] integrate symbolic expression in dynamic_dimension #4702
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 87 commits
Commits
Show all changes
88 commits
Select commit
Hold shift + click to select a range
d2b684e
custom symbolic expression lib
shivadbhavsar aa55785
format
shivadbhavsar 314f7cf
use visit
shivadbhavsar dcfe825
format
shivadbhavsar 2ec0969
integrate symbolic expression in dynamic_dimension
shivadbhavsar 18caf6b
tidy
shivadbhavsar 483932b
Merge branch 'custom_sym_lib' into sym_dim_integration
shivadbhavsar 200f3c4
Merge branch 'develop' into custom_sym_lib
shivadbhavsar 7ff2045
Merge branch 'custom_sym_lib' into sym_dim_integration
shivadbhavsar 6af3621
fix constructor ambiguity
shivadbhavsar b7d7c23
fix ambiguity
shivadbhavsar 3486135
update namespace and interface design
shivadbhavsar edbce87
Merge branch 'develop' into custom_sym_lib
shivadbhavsar 964f934
use int64 for literals
shivadbhavsar 2719ae6
Merge branch 'custom_sym_lib' into sym_dim_integration
shivadbhavsar 364bd23
fix merge
shivadbhavsar 33614e0
change eval func name
shivadbhavsar 2ba3b74
Merge branch 'custom_sym_lib' into sym_dim_integration
shivadbhavsar 830594f
use int64 for internal eval
shivadbhavsar bd70d84
Merge branch 'custom_sym_lib' into sym_dim_integration
shivadbhavsar def3038
fix eval call
shivadbhavsar 359070d
copilot comments
shivadbhavsar 9ad996f
copilot review fix
shivadbhavsar b61b6d8
Merge branch 'custom_sym_lib' into sym_dim_integration
shivadbhavsar bda9f91
format and tidy
shivadbhavsar 5027376
Merge branch 'custom_sym_lib' into sym_dim_integration
shivadbhavsar 1209717
Merge branch 'sym_dim_integration' of https://github.com/ROCm/AMDMIGr…
shivadbhavsar 003c9d3
tidy fix
shivadbhavsar 3759299
tidy
shivadbhavsar 50944fb
Merge remote-tracking branch 'origin/custom_sym_lib' into sym_dim_int…
shivadbhavsar fe649ff
update the only call sites using the braced-init-list that cannot be …
shivadbhavsar 7be6e7f
Merge remote-tracking branch 'origin/develop' into custom_sym_lib
shivadbhavsar 1274d3a
address review comments
shivadbhavsar 5b28774
Merge remote-tracking branch 'origin/custom_sym_lib' into sym_dim_int…
shivadbhavsar 83da044
license
shivadbhavsar d680d55
reduce complexity
shivadbhavsar 8d5629b
Merge remote-tracking branch 'origin/custom_sym_lib' into sym_dim_int…
shivadbhavsar e7ca1d6
update calls to eval_uint
shivadbhavsar 54debb5
clean up test file
shivadbhavsar c7f698c
review comments
shivadbhavsar 149b661
Merge remote-tracking branch 'origin/custom_sym_lib' into sym_dim_int…
shivadbhavsar 293b5d8
merge and tidy
shivadbhavsar cc521e4
license
shivadbhavsar 3b7077a
Merge remote-tracking branch 'origin/custom_sym_lib' into sym_dim_int…
shivadbhavsar 47ec30a
fix style
shivadbhavsar 59a7ef4
normalize fixed dynamic dim representation
shivadbhavsar 95894db
fmt
shivadbhavsar be87f71
fix serialization and normalization
shivadbhavsar 78f06c7
license
shivadbhavsar 71d7ae7
Merge branch 'develop' into sym_dim_integration
shivadbhavsar 1a68619
address review comments
shivadbhavsar 2044073
Merge branch 'develop' into sym_dim_integration
shivadbhavsar d6c8d49
update tests for cleaned up intersection logic
shivadbhavsar 4556366
Merge branch 'develop' into sym_dim_integration
shivadbhavsar 378e3d7
review feedback updates
shivadbhavsar 5412e60
Merge branch 'develop' into sym_dim_integration
shivadbhavsar 0bf5680
fix tidy
shivadbhavsar 4fa771a
Merge branch 'develop' into sym_dim_integration
shivadbhavsar 2545a8e
fix callsite to remove disambiguity
shivadbhavsar e904332
Merge branch 'develop' into sym_dim_integration
shivadbhavsar c8b8df4
fix merge
shivadbhavsar 4e0da9c
remove optional from sym_expr
shivadbhavsar ca454b2
refactor how dyn dim intervals are stored and accessed
shivadbhavsar 29ca4d5
add defaults
shivadbhavsar a0026ba
add getter for optimals and update callsites
shivadbhavsar 1db31d6
update to use get_interval() and remove min() and max()
shivadbhavsar c128adc
fix cppcheck
shivadbhavsar 3b2c259
return optimals by value
shivadbhavsar 49d7aa6
Merge remote-tracking branch 'origin/develop' into dyn_interval_refactor
shivadbhavsar cc74c4a
update has_optimal
shivadbhavsar 44cd175
symbolic dimension integration (squashed)
shivadbhavsar ae322fc
update implementation to work on top of inverval refactor
shivadbhavsar 7b5484e
Merge branch 'sym_dim_integration' of https://github.com/ROCm/AMDMIGr…
shivadbhavsar 39e0442
Merge remote-tracking branch 'origin/develop' into sym_dim_integration
shivadbhavsar 5be3d69
fix old constructor
shivadbhavsar 093964c
fix ambiguous call
shivadbhavsar 72f00ea
fix cppcheck
shivadbhavsar 812a1b1
add missing comment blocks
shivadbhavsar 8573cfb
clearly state assumptions used when dealing with stride permutations …
shivadbhavsar 718e599
Merge branch 'develop' into sym_dim_integration
shivadbhavsar d94f367
add missing tests
shivadbhavsar 1747639
Merge branch 'develop' into sym_dim_integration
shivadbhavsar 3e0e2c2
make var bounds non-optional and add deprecation TODO to clarify the …
shivadbhavsar 4bbb2e6
Merge branch 'develop' into sym_dim_integration
shivadbhavsar 94c7941
add scalar variant to ease merging 4782
shivadbhavsar a64a0d1
fix brace-init ambiguity for sles
shivadbhavsar c4a33e1
wrap scalar variant to handle ambuigity
shivadbhavsar 3887e3f
use migraphx_requires and fix tidy
shivadbhavsar 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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -28,8 +28,11 @@ | |
| #include <cstdint> | ||
| #include <memory> | ||
| #include <ostream> | ||
| #include <set> | ||
| #include <string> | ||
| #include <type_traits> | ||
| #include <unordered_map> | ||
| #include <variant> | ||
|
|
||
| #include <migraphx/config.hpp> | ||
|
|
||
|
|
@@ -40,8 +43,48 @@ struct value; | |
|
|
||
| namespace sym { | ||
|
|
||
| // Scalar value held by literal expressions and interval bounds. Wraps a | ||
| // variant so that integer-literal initialization is unambiguous on stricter | ||
| // libstdc++ versions. | ||
| struct scalar | ||
| { | ||
| std::variant<int64_t, double> value; | ||
|
|
||
| constexpr scalar() = default; | ||
|
|
||
| template <class T, std::enable_if_t<std::is_integral_v<T>, int> = 0> | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Use |
||
| constexpr scalar(T v) : value{int64_t{v}} // NOLINT(google-explicit-constructor) | ||
| { | ||
| } | ||
|
|
||
| template <class T, std::enable_if_t<std::is_floating_point_v<T>, int> = 0> | ||
| constexpr scalar(T v) : value{double{v}} // NOLINT(google-explicit-constructor) | ||
| { | ||
| } | ||
|
|
||
| friend bool operator==(const scalar& a, const scalar& b) { return a.value == b.value; } | ||
| friend bool operator!=(const scalar& a, const scalar& b) { return not(a == b); } | ||
| }; | ||
|
|
||
| template <class To> | ||
| To to(const scalar& v) | ||
| { | ||
| return std::visit([](auto x) -> To { return x; }, v.value); | ||
| } | ||
|
|
||
| struct interval | ||
| { | ||
| scalar min = int64_t{0}; | ||
| scalar max = int64_t{0}; | ||
| friend bool operator==(const interval& a, const interval& b) | ||
| { | ||
| return a.min == b.min and a.max == b.max; | ||
| } | ||
| friend bool operator!=(const interval& a, const interval& b) { return not(a == b); } | ||
| }; | ||
|
|
||
| struct expr; | ||
| MIGRAPHX_EXPORT expr var(const std::string& name); | ||
| MIGRAPHX_EXPORT expr var(const std::string& name, interval bounds, std::set<int64_t> optimals = {}); | ||
| MIGRAPHX_EXPORT expr lit(int64_t n); | ||
| MIGRAPHX_EXPORT expr parse(const std::string& s); | ||
|
|
||
|
|
@@ -50,11 +93,14 @@ struct MIGRAPHX_EXPORT expr | |
| expr(); | ||
|
|
||
| bool empty() const; | ||
| bool is_literal() const; | ||
| std::size_t hash() const; | ||
| std::string to_string() const; | ||
| value to_value() const; | ||
| void from_value(const value& v); | ||
| std::size_t eval_uint(const std::unordered_map<expr, std::size_t>& symbol_map) const; | ||
| interval eval_interval() const; | ||
| std::set<std::size_t> eval_optimals() const; | ||
| expr subs(const std::unordered_map<expr, expr>& symbol_map) const; | ||
|
|
||
| MIGRAPHX_EXPORT friend expr operator+(const expr& a, const expr& b); | ||
|
|
@@ -63,6 +109,10 @@ struct MIGRAPHX_EXPORT expr | |
| MIGRAPHX_EXPORT friend expr operator/(const expr& a, const expr& b); | ||
| MIGRAPHX_EXPORT friend bool operator==(const expr& a, const expr& b); | ||
| MIGRAPHX_EXPORT friend bool operator!=(const expr& a, const expr& b); | ||
| MIGRAPHX_EXPORT friend bool operator<(const expr& a, const expr& b); | ||
| friend bool operator>(const expr& a, const expr& b) { return b < a; } | ||
| friend bool operator<=(const expr& a, const expr& b) { return not(b < a); } | ||
| friend bool operator>=(const expr& a, const expr& b) { return not(a < b); } | ||
| MIGRAPHX_EXPORT friend std::ostream& operator<<(std::ostream& os, const expr& e); | ||
|
|
||
| friend expr operator+(const expr& a, int64_t b) { return a + lit(b); } | ||
|
|
@@ -76,7 +126,8 @@ struct MIGRAPHX_EXPORT expr | |
|
|
||
| struct impl; | ||
|
|
||
| MIGRAPHX_EXPORT friend expr var(const std::string& name); | ||
| MIGRAPHX_EXPORT friend expr | ||
| var(const std::string& name, interval bounds, std::set<int64_t> optimals); | ||
| MIGRAPHX_EXPORT friend expr lit(int64_t n); | ||
| MIGRAPHX_EXPORT friend expr parse(const std::string& s); | ||
|
|
||
|
|
||
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.