-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[NODE][IR] Introduce StructuralEqual Infra for the unified IR. (#5154)
* [NODE][IR] Introduce StructuralEqual Infra for the Unified IR. This PR introduces a new way to handle structural equality for both TIR and relay nodes in an extensive way. - Each object can now register an optional SEqualReduce function, which describes how to reduce its structural equality to another instance into equality of the children. - Optionally, the object can choose to allow remapping of vars(e.g. function parameters) by calling DefEqual - We implemented a non-recursive structural equality checker that recursively traverses the objects and does the structural equality checking. This PR also fixes a few potential problems in previous relay's AlphaEqual. - In particular, the new structural equality relation will be communicative. - It is can be dangerous to use same_as relation to quickly check equality, demonstrated by the following case. (%x, %y) are shared vars between two functions. - function0: fn (%x, %y) { %x + %y } - function1: fn (%y, %x) { %x + %y } The new structural equal is intented to supersede AlphaEqual and AttrsEqual. Follow-up PRs should be performed to redirect the existing usages, and removes the corresponding implementation. * Update the rule to distinguish between graph node and non-graph nodes. * Refactor the test cases to use structural equal. * address comments * Mark more relay::Expr as graph node, fix a testcase issue(was bug that was not caught by previous alpha equal) * Remove unrelated comment * Fix file comment * Address review comment * Relax condition to fit flaky case
- Loading branch information
Showing
46 changed files
with
1,781 additions
and
271 deletions.
There are no files selected for viewing
This file contains 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 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 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 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 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 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 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 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 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 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 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 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
Oops, something went wrong.