Skip to content

Commit e26dece

Browse files
committed
Add support for dynamo
1 parent d37127f commit e26dece

File tree

2 files changed

+11
-4
lines changed

2 files changed

+11
-4
lines changed

test/dynamo/test_dynamo_graph_dump.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,14 @@ def test_dump_graph_with_dynamo_execution(self):
3232
xla_y = torch.tensor(200.0).to(device)
3333
res_xla_dynamo = self.fn_simple_dynamo(xla_x, xla_y)
3434
with open(save_file, 'rb') as f:
35-
current_line = sum(1 for line in f)
35+
lines = f.readlines()
36+
current_line = len(lines)
37+
self.assertIn('Graph Hash:', lines[-5].decode())
3638
with open(save_file, 'rb') as f:
3739
res_xla_dynamo_2 = self.fn_simple_dynamo(xla_x, xla_y)
38-
new_line = sum(1 for line in f)
40+
lines = f.readlines()
41+
new_line = len(lines)
42+
self.assertIn('Graph Hash:', lines[-5].decode())
3943
self.assertGreater(new_line, current_line)
4044

4145

torch_xla/csrc/xla_graph_executor.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -146,8 +146,11 @@ void XLAGraphExecutor::DeviceContextArena::SaveGraphAsString(
146146
"";
147147
if (should_save_graph &&
148148
hash_to_graph_map.find(hash) == hash_to_graph_map.end()) {
149-
hash_to_graph_map[hash] =
150-
DebugUtil::GetTensorsGraphInfo(tensors, indices, format);
149+
std::stringstream ss;
150+
ss << DebugUtil::GetTensorsGraphInfo(tensors, indices, format);
151+
ss << "Graph Hash: " << torch::lazy::HashToString(hash)
152+
<< "\n\n## END_GRAPH\n\n";
153+
hash_to_graph_map[hash] = ss.str();
151154
}
152155
}
153156

0 commit comments

Comments
 (0)