-
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
Changes from 86 commits
d2b684e
aa55785
314f7cf
dcfe825
2ec0969
18caf6b
483932b
200f3c4
7ff2045
6af3621
b7d7c23
3486135
edbce87
964f934
2719ae6
364bd23
33614e0
2ba3b74
830594f
bd70d84
def3038
359070d
9ad996f
b61b6d8
bda9f91
5027376
1209717
003c9d3
3759299
50944fb
fe649ff
7be6e7f
1274d3a
5b28774
83da044
d680d55
8d5629b
e7ca1d6
54debb5
c7f698c
149b661
293b5d8
cc521e4
3b7077a
47ec30a
59a7ef4
95894db
be87f71
78f06c7
71d7ae7
1a68619
2044073
d6c8d49
4556366
378e3d7
5412e60
0bf5680
4fa771a
2545a8e
e904332
c8b8df4
4e0da9c
ca454b2
29ca4d5
a0026ba
1db31d6
c128adc
3b2c259
49d7aa6
cc74c4a
44cd175
ae322fc
7b5484e
39e0442
5be3d69
093964c
72f00ea
812a1b1
8573cfb
718e599
d94f367
1747639
3e0e2c2
4bbb2e6
94c7941
a64a0d1
c4a33e1
3887e3f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| 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 <unordered_map> | ||
| #include <utility> | ||
| #include <variant> | ||
|
|
||
| #include <migraphx/config.hpp> | ||
|
|
||
|
|
@@ -40,8 +43,36 @@ | |
|
|
||
| namespace sym { | ||
|
|
||
| using scalar = std::variant<int64_t, double>; | ||
|
|
||
| template <class To> | ||
| To to(const scalar& v) | ||
| { | ||
| return std::visit([](auto x) -> To { return x; }, v); | ||
| } | ||
|
|
||
| struct interval | ||
| { | ||
| scalar min = int64_t{0}; | ||
| scalar max = int64_t{0}; | ||
|
|
||
| interval() = default; | ||
| interval(scalar mn, scalar mx) : min{std::move(mn)}, max{std::move(mx)} {} | ||
|
Check warning on line 60 in src/include/migraphx/sym.hpp
|
||
| // Convenience overload so brace-init with bare integer literals (e.g. | ||
| // `interval{1, 8}` or `var("n", {1, 8})`) resolves unambiguously rather | ||
| // than triggering the variant converting-ctor's int-vs-double tie that | ||
| // some libstdc++ versions (notably on SLES) reject. | ||
| interval(int64_t mn, int64_t mx) : min{mn}, max{mx} {} | ||
|
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. Is this really needed? The problem is that we cant write
Contributor
Author
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. even without this i think |
||
|
|
||
| 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 +81,14 @@ | |
| 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 +97,10 @@ | |
| 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 +114,8 @@ | |
|
|
||
| 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); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.