Skip to content

Commit 14ecc03

Browse files
Revert "recovering node source from dict (pytorch#158373)"
This reverts commit 4d05598. Reverted pytorch#158373 on behalf of https://github.com/facebook-github-bot due to Diff reverted internally ([comment](pytorch#158373 (comment)))
1 parent 1cc62c2 commit 14ecc03

File tree

2 files changed

+6
-65
lines changed

2 files changed

+6
-65
lines changed

test/fx/test_fx_traceback.py

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -32,8 +32,6 @@ def test_node_source(self):
3232
dummy_source_dict,
3333
)
3434

35-
self.assertEqual(node_source, NodeSource._from_dict(node_source.to_dict()))
36-
3735
# Dummy node
3836
node = torch.fx.Node(
3937
graph=torch.fx.Graph(),
@@ -181,28 +179,14 @@ def forward(self, x):
181179
if node_name_1 in same_ancestor_nodes
182180
else None,
183181
}:
184-
self.assertEqual(
185-
node_name_to_from_node[node_name_1],
186-
node_name_to_from_node[node_name_2],
187-
)
188-
self.assertEqual(
189-
[
190-
NodeSource._from_dict(ns.to_dict())
191-
for ns in node_name_to_from_node[node_name_1]
192-
],
193-
node_name_to_from_node[node_name_2],
182+
self.assertTrue(
183+
node_name_to_from_node[node_name_1]
184+
== node_name_to_from_node[node_name_2]
194185
)
195186
else:
196-
self.assertNotEqual(
197-
node_name_to_from_node[node_name_1],
198-
node_name_to_from_node[node_name_2],
199-
)
200-
self.assertNotEqual(
201-
[
202-
NodeSource._from_dict(ns.to_dict())
203-
for ns in node_name_to_from_node[node_name_1]
204-
],
205-
node_name_to_from_node[node_name_2],
187+
self.assertTrue(
188+
node_name_to_from_node[node_name_1]
189+
!= node_name_to_from_node[node_name_2]
206190
)
207191

208192
gm = ep.module()

torch/fx/traceback.py

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -152,49 +152,6 @@ def _make_hashable(obj):
152152

153153
return hash(_make_hashable(self.to_dict()))
154154

155-
@classmethod
156-
def _from_dict(cls, d: Optional[dict]) -> Optional["NodeSource"]:
157-
"""
158-
Recursively deserialize from_node metadata from dictionary data.
159-
It is used to deserialize the from_node field from serialized metadata.
160-
Please use contructor NodeSource(node, ...) to create a NodeSource object.
161-
"""
162-
if d is None:
163-
return None
164-
165-
assert isinstance(d, dict), f"Expected a dict, got {type(d)}"
166-
167-
# Create a NodeSource object directly without going through the constructor
168-
# to avoid issues with graph ID and node creation
169-
node_source = NodeSource.__new__(NodeSource)
170-
171-
# Set the basic attributes
172-
node_source.pass_name = d.get("pass_name", "")
173-
174-
# Parse action string back to NodeSourceAction enum list
175-
action_str = d.get("action", "")
176-
actions = []
177-
if action_str:
178-
for action_name in action_str.split("+"):
179-
if action_name.upper() == "CREATE":
180-
actions.append(NodeSourceAction.CREATE)
181-
elif action_name.upper() == "REPLACE":
182-
actions.append(NodeSourceAction.REPLACE)
183-
node_source.action = actions
184-
185-
# Create the NodeInfo object directly
186-
if "name" in d and "target" in d and "graph_id" in d:
187-
node_info = NodeSource.NodeInfo(
188-
d.get("name", ""), d.get("target", ""), d.get("graph_id", -1)
189-
)
190-
node_source.node_info = node_info
191-
else:
192-
node_source.node_info = None
193-
194-
# Recursively deserialize nested from_node
195-
node_source.from_node = [cls._from_dict(fn) for fn in d.get("from_node", [])]
196-
return node_source
197-
198155

199156
@compatibility(is_backward_compatible=False)
200157
@contextmanager

0 commit comments

Comments
 (0)