Commit f5cbe18
authored
Change loop order during rewrite (#2427)
Change the loop order when applying a collection of rewrite-rules to all
nodes in graph. The order in this PR is preferable, for a couple of
reasons.
First: rules often have mutual dependences, with one rule enabling
another. This loop-ordering handles such dependences better, and does so
more efficiently (requiring fewer iterations of yet another outer loop
to invoke the rewriter multiple times).
It also sets it up for another optimization planned for originally (but
not yet implemented): For patterns that end with a definite op (like
ScatterND), which are most of the rules/patterns, we can create a
dictionary mapping the op-identifier to rules applicable to that op.
Then, it is sufficient to iterate only over rules applicable to current
node's op.
Signed-off-by: Ganesan Ramalingam <grama@microsoft.com>1 parent ff0a132 commit f5cbe18
1 file changed
+6
-3
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
465 | 465 | | |
466 | 466 | | |
467 | 467 | | |
468 | | - | |
469 | | - | |
470 | 468 | | |
471 | 469 | | |
472 | 470 | | |
473 | | - | |
| 471 | + | |
| 472 | + | |
| 473 | + | |
474 | 474 | | |
475 | 475 | | |
476 | 476 | | |
| |||
549 | 549 | | |
550 | 550 | | |
551 | 551 | | |
| 552 | + | |
| 553 | + | |
| 554 | + | |
552 | 555 | | |
553 | 556 | | |
554 | 557 | | |
| |||
0 commit comments