Skip to content

Commit

Permalink
Update
Browse files Browse the repository at this point in the history
[ghstack-poisoned]
  • Loading branch information
ezyang committed Apr 30, 2024
1 parent 3a49496 commit eec75a5
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 14 deletions.
1 change: 1 addition & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,7 @@ pub fn parse_path(path: &PathBuf, config: ParseConfig) -> anyhow::Result<ParseOu

let index_context = IndexContext {
css: CSS,
javascript: JAVASCRIPT,
directory: directory
.drain(..)
.map(|(x, y)| (x.map_or("(unknown)".to_string(), |e| e.to_string()), y))
Expand Down
30 changes: 29 additions & 1 deletion src/templates.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,29 @@
pub static CSS: &str = r#"
.stack-trie { white-space: nowrap; font-family: monospace; }
.stack-trie ul { padding-left: 1ch; }
.stack-trie li { margin-left: 1ch; list-style-type: none; }
.stack-trie .marker {
cursor: pointer;
}
.stack-trie .marker.collapsed::before {
content: "+ ";
}
.stack-trie .marker:not(.collapsed)::before {
content: "- ";
}
"#;

pub static JAVASCRIPT: &str = r#"
function toggleList(toggleItem) {
const listItem = toggleItem.parentNode;
const nestedList = listItem.querySelector('ul');
if (nestedList) {
nestedList.style.display = nestedList.style.display === 'none' ? 'block' : 'none';
// Toggle the collapse/expand indicator
toggleItem.classList.toggle('collapsed');
}
}
"#;

pub static TEMPLATE_DYNAMO_GUARDS: &str = r#"
Expand All @@ -17,8 +42,11 @@ pub static TEMPLATE_DYNAMO_GUARDS: &str = r#"
pub static TEMPLATE_INDEX: &str = r#"
<html>
<style>
{css}
{css | format_unescaped}
</style>
<script>
{javascript | format_unescaped}
</script>
<body>
<div>
<h2>Stack trie</h2>
Expand Down
21 changes: 8 additions & 13 deletions src/types.rs
Original file line number Diff line number Diff line change
Expand Up @@ -45,23 +45,15 @@ impl StackTrieNode {
// If the node has multiple children, increase the indent and print a hyphen
writeln!(
f,
"{:indent$}- {star}{}",
"",
"<li><span onclick='toggleList(this)' class='marker'></span>{star}{}<ul>",
frame,
indent = indent,
star = star
)?;
node.fmt_inner(f, indent + 2)?;
write!(f, "</ul></li>")?;
} else {
// If the node has only one child, don't increase the indent and don't print a hyphen
writeln!(
f,
"{:indent$} {star}{}",
"",
frame,
indent = indent,
star = star
)?;
writeln!(f, "<li>{star}{}</li>", frame, star = star)?;
node.fmt_inner(f, indent)?;
}
}
Expand All @@ -71,9 +63,11 @@ impl StackTrieNode {

impl Display for StackTrieNode {
fn fmt(&self, f: &mut Formatter) -> fmt::Result {
write!(f, "<pre>")?;
write!(f, "<div class='stack-trie'>")?;
write!(f, "<ul>")?;
self.fmt_inner(f, 0)?;
write!(f, "</pre>")?;
write!(f, "</ul>")?;
write!(f, "</div>")?;
Ok(())
}
}
Expand Down Expand Up @@ -330,6 +324,7 @@ pub struct DynamoGuardsContext {
#[derive(Debug, Serialize)]
pub struct IndexContext {
pub css: &'static str,
pub javascript: &'static str,
pub directory: Vec<(String, Vec<(PathBuf, i32)>)>,
pub stack_trie_html: String,
pub unknown_stack_trie_html: String,
Expand Down
2 changes: 2 additions & 0 deletions tests/inputs/simple.log
Original file line number Diff line number Diff line change
Expand Up @@ -254,3 +254,5 @@ V0401 08:54:22.980000 140424060892160 torch/_dynamo/guards.py:1194] {"dynamo_gua
{"code": "___check_current_backend(140423721840560)", "stack": [{"line": 10031, "name": "<module>", "filename": 0}, {"line": 14, "name": "run_tests", "filename": 1}, {"line": 41, "name": "run_tests", "filename": 2}, {"line": 1165, "name": "run_tests", "filename": 3}, {"line": 101, "name": "__init__", "filename": 4}, {"line": 271, "name": "runTests", "filename": 4}, {"line": 184, "name": "run", "filename": 5}, {"line": 84, "name": "__call__", "filename": 6}, {"line": 122, "name": "run", "filename": 6}, {"line": 84, "name": "__call__", "filename": 6}, {"line": 122, "name": "run", "filename": 6}, {"line": 650, "name": "__call__", "filename": 7}, {"line": 2866, "name": "run", "filename": 3}, {"line": 2838, "name": "_run_custom", "filename": 3}, {"line": 591, "name": "run", "filename": 7}, {"line": 549, "name": "_callTestMethod", "filename": 7}, {"line": 2739, "name": "wrapper", "filename": 3}, {"line": 9214, "name": "new_test", "filename": 0}, {"line": 79, "name": "inner", "filename": 8}, {"line": 8845, "name": "test_custom_op_fixed_layout_channels_last", "filename": 0}, {"line": 1527, "name": "_wrapped_call_impl", "filename": 9}, {"line": 1536, "name": "_call_impl", "filename": 9}, {"line": 450, "name": "_fn", "filename": 10}, {"line": 1527, "name": "_wrapped_call_impl", "filename": 9}, {"line": 1536, "name": "_call_impl", "filename": 9}, {"line": 939, "name": "catch_errors", "filename": 11}, {"line": 802, "name": "_convert_frame", "filename": 11}, {"line": 400, "name": "_convert_frame_assert", "filename": 11}, {"line": 79, "name": "inner", "filename": 8}, {"line": 686, "name": "_compile", "filename": 11}, {"line": 262, "name": "time_wrapper", "filename": 12}, {"line": 541, "name": "compile_inner", "filename": 11}, {"line": 1036, "name": "transform_code_object", "filename": 13}, {"line": 165, "name": "_fn", "filename": 11}, {"line": 485, "name": "transform", "filename": 11}, {"line": 2105, "name": "__init__", "filename": 14}, {"line": 344, "name": "__init__", "filename": 15}, {"line": 473, "name": "init_ambient_guards", "filename": 15}], "user_stack": null},
{"code": "check_tensor(L['x'], Tensor, DispatchKeySet(CUDA, BackendSelect, ADInplaceOrView, AutogradCUDA), torch.float32, device=0, requires_grad=False, size=[1, 320, 128, 128], stride=[5242880, 1, 40960, 320])", "stack": null, "user_stack": null}
]
V0401 08:54:21.882000 140424060892160 torch/_dynamo/convert_frame.py:672] {"dynamo_start": {"stack": [{"line": 10031, "name": "<module>", "filename": 0}, {"line": 14, "name": "run_tests", "filename": 1}, {"line": 41, "name": "run_tests", "filename": 2}, {"line": 1165, "name": "run_tests", "filename": 3}, {"line": 101, "name": "__init__", "filename": 4}, {"line": 271, "name": "runTests", "filename": 4}, {"line": 184, "name": "run", "filename": 5}, {"line": 84, "name": "__call__", "filename": 6}, {"line": 122, "name": "run", "filename": 6}, {"line": 84, "name": "__call__", "filename": 6}, {"line": 122, "name": "run", "filename": 6}, {"line": 650, "name": "__call__", "filename": 7}, {"line": 2866, "name": "run2", "filename": 3}, {"line": 2838, "name": "_run_custom", "filename": 3}, {"line": 591, "name": "run", "filename": 7}, {"line": 549, "name": "_callTestMethod", "filename": 7}, {"line": 2739, "name": "wrapper", "filename": 3}, {"line": 9214, "name": "new_test", "filename": 0}, {"line": 79, "name": "inner", "filename": 8}, {"line": 8845, "name": "test_custom_op_fixed_layout_channels_last", "filename": 0}, {"line": 1527, "name": "_wrapped_call_impl", "filename": 9}, {"line": 1536, "name": "_call_impl", "filename": 9}, {"line": 450, "name": "_fn", "filename": 10}, {"line": 1527, "name": "_wrapped_call_impl", "filename": 9}, {"line": 1536, "name": "_call_impl", "filename": 9}]}, "frame_id": 0, "frame_compile_id": 0, "attempt": 0}
V0401 08:54:21.882000 140424060892160 torch/_dynamo/convert_frame.py:672] {"dynamo_start": {"stack": [{"line": 10031, "name": "<module>", "filename": 0}, {"line": 14, "name": "run_tests", "filename": 1}, {"line": 41, "name": "run_tests", "filename": 2}, {"line": 1165, "name": "run_tests", "filename": 3}, {"line": 101, "name": "__init__", "filename": 4}, {"line": 271, "name": "runTests", "filename": 4}, {"line": 184, "name": "run", "filename": 5}, {"line": 84, "name": "__call__", "filename": 6}, {"line": 122, "name": "run", "filename": 6}, {"line": 84, "name": "__call__", "filename": 6}, {"line": 122, "name": "run", "filename": 6}, {"line": 650, "name": "__call__", "filename": 7}, {"line": 2866, "name": "run2", "filename": 3}, {"line": 2838, "name": "_run_custom", "filename": 3}, {"line": 591, "name": "run", "filename": 7}, {"line": 549, "name": "_callTestMethod", "filename": 7}, {"line": 2739, "name": "wrapper", "filename": 3}, {"line": 9214, "name": "new_test", "filename": 0}, {"line": 79, "name": "inner", "filename": 8}, {"line": 8845, "name": "test_custom_op_fixed_layout_channels_last", "filename": 0}, {"line": 1527, "name": "_wrapped_call_impl", "filename": 9}, {"line": 1536, "name": "_call_impl", "filename": 9}, {"line": 450, "name": "_fn", "filename": 10}, {"line": 1527, "name": "_wrapped_call_implaa", "filename": 9}, {"line": 1536, "name": "_call_impl", "filename": 9}]}, "frame_id": 0, "frame_compile_id": 0, "attempt": 0}

0 comments on commit eec75a5

Please sign in to comment.