-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[IR] Improve name authority to generate unique names (#1537)
- Store all names from the graph for generating unique names for new values. - Also allow values to be initialized with no arguments. Fix #1535
- Loading branch information
1 parent
ebee154
commit 2b6dc27
Showing
7 changed files
with
115 additions
and
41 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
# ------------------------------------------------------------------------- | ||
# Copyright (c) Microsoft Corporation. All rights reserved. | ||
# Licensed under the MIT License. | ||
# -------------------------------------------------------------------------- | ||
import unittest | ||
|
||
from onnxscript import ir | ||
from onnxscript.ir import _name_authority | ||
|
||
|
||
class NameAuthorityTest(unittest.TestCase): | ||
def test_register_or_name_value(self): | ||
name_authority = _name_authority.NameAuthority() | ||
value = ir.Value() | ||
name_authority.register_or_name_value(value) | ||
self.assertEqual(value.name, "val_0") | ||
|
||
def test_register_or_name_node(self): | ||
name_authority = _name_authority.NameAuthority() | ||
node = ir.Node("", "Test", []) | ||
name_authority.register_or_name_node(node) | ||
self.assertEqual(node.name, "node_Test_0") | ||
|
||
|
||
if __name__ == "__main__": | ||
unittest.main() |
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