-
-
Notifications
You must be signed in to change notification settings - Fork 153
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
Remove add_mul_fusion
rewrite
#1243
base: main
Are you sure you want to change the base?
Conversation
@@ -896,16 +896,16 @@ def print_profile(cls, stream, prof, level=0): | |||
print(blanc, " time_toposort", prof[7], file=stream) | |||
|
|||
|
|||
fuse_seqopt = SequenceDB() |
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.
This was potentially buggy, as fuse_seqopt
was always being imported by the other module, even though it's creation was conditional on a config flag.
cd076e1
to
9b61381
Compare
@@ -896,16 +896,16 @@ def print_profile(cls, stream, prof, level=0): | |||
print(blanc, " time_toposort", prof[7], file=stream) | |||
|
|||
|
|||
fuse_seqopt = SequenceDB() |
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.
Also, should we get rid of it if we have only a single rewrite now?
9b61381
to
14697eb
Compare
Codecov Report
Additional details and impacted files@@ Coverage Diff @@
## main #1243 +/- ##
==========================================
+ Coverage 79.14% 79.17% +0.03%
==========================================
Files 173 173
Lines 48528 48503 -25
Branches 10322 10315 -7
==========================================
- Hits 38408 38403 -5
+ Misses 7628 7613 -15
+ Partials 2492 2487 -5
|
Sometimes the import aesara
import aesara.tensor as at
from aesara.compile.mode import Mode
x, y, z = at.vectors("x", "y", "z")
mul = x * y * z
add = x + y + z
out = mul - add
f = aesara.function([x, y, z], [out], mode=Mode().including("canonicalize").excluding("fusion"))
aesara.dprint(f)
Or, conversely out = add / mul
f = aesara.function([x, y, z], [out], mode=Mode().including("canonicalize").excluding("fusion"))
aesara.dprint(f)
|
14697eb
to
fbbe4ff
Compare
|
@@ -896,16 +896,16 @@ def print_profile(cls, stream, prof, level=0): | |||
print(blanc, " time_toposort", prof[7], file=stream) | |||
|
|||
|
|||
fuse_seqopt = SequenceDB() | |||
if config.tensor__local_elemwise_fusion: |
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.
I haven't thought enough about this just yet, but it really looks like we need to consider removing this option entirely, because, unless we redesign the whole approach to fusion/FusionOptimizer
, I don't know whether this idea of applying a graph (i.e. "global") rewriter on each node (i.e. "locally") makes any sense.
I could see a place for a distinct node-based fusion rewrite, but I really don't think it would/should operate anything like a graph-based rewrite (e.g. it seems like there would be way too much unnecessary graph walking).
In general, the idea of a node-based fusion rewrite sounds appealing, because it could be a lot simpler than the/a graph-based one, but I don't know which types of graphs the former would miss that the latter wouldn't.
The same job is done by canonicalize before this rewrite is ever called.
fbbe4ff
to
9e638e3
Compare
add_mul_fusion
rewrite
Some cleanup that emerged while working on #1242
The point of this rewrite was to fuse nested
add
andmul
operations into a singleadd
/mul
. This however is always (and more completely) done by canonicalization before the rewrite is ever triggered. As evidence of this, removing this rewrite would not cause any of the Fusion related tests to fail.I also added a direct rewrite for the desired behavior, of giving precedence to fusing
add
/mul
beforecomposites
are introduced.