diff --git a/src/lib.rs b/src/lib.rs index 509a735..f147837 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -491,6 +491,8 @@ pub fn parse_path(path: &PathBuf, config: &ParseConfig) -> anyhow::Result = RefCell::new(FxHashMap::default()); let sym_expr_info_index: RefCell = RefCell::new(FxHashMap::default()); + let create_symbol_index: RefCell = RefCell::new(FxHashMap::default()); + let unbacked_symbol_index: RefCell = RefCell::new(FxHashMap::default()); // Store results in an output ParseOutput let mut output: ParseOutput = Vec::new(); @@ -819,6 +821,8 @@ pub fn parse_path(path: &PathBuf, config: &ParseConfig) -> anyhow::Result anyhow::Result anyhow::Result { pub stack_index: &'t RefCell, pub symbolic_shape_specialization_index: &'t RefCell, pub guard_added_fast_index: &'t RefCell, + pub create_symbol_index: &'t RefCell, + pub unbacked_symbol_index: &'t RefCell, pub output_files: &'t Vec, pub compile_id_dir: &'t PathBuf, } @@ -486,6 +488,50 @@ impl StructuredLogParser for CompilationMetricsParser<'_> { ), }) .collect(); + let create_symbols = self + .create_symbol_index + .borrow_mut() + .remove(&cid) + .unwrap_or(Vec::new()) + .drain(..) + .map(|sym| CreateSymbolContext { + symbol: sym.symbol.unwrap_or("".to_string()), + val: sym.val.unwrap_or("".to_string()), + vr: sym.vr.unwrap_or("".to_string()), + source: sym.source.unwrap_or("".to_string()), + user_stack_html: format_stack( + &sym.user_stack.unwrap_or(Vec::new()), + "User Stack", + false, + ), + stack_html: format_stack( + &sym.stack.unwrap_or(Vec::new()), + "Framework Stack", + false, + ), + }) + .collect(); + let unbacked_symbols = self + .unbacked_symbol_index + .borrow_mut() + .remove(&cid) + .unwrap_or(Vec::new()) + .drain(..) + .map(|sym| UnbackedSymbolContext { + symbol: sym.symbol.unwrap_or("".to_string()), + vr: sym.vr.unwrap_or("".to_string()), + user_stack_html: format_stack( + &sym.user_stack.unwrap_or(Vec::new()), + "User Stack", + false, + ), + stack_html: format_stack( + &sym.stack.unwrap_or(Vec::new()), + "Framework Stack", + false, + ), + }) + .collect(); let remove_prefix = |x: &String| -> String { // url is X_Y_Z/. Get the rest of the string for the link // on compilation metrics page @@ -512,6 +558,8 @@ impl StructuredLogParser for CompilationMetricsParser<'_> { mini_stack_html: mini_stack_html, symbolic_shape_specializations: specializations, guards_added_fast: guards_added_fast, + create_symbols: create_symbols, + unbacked_symbols: unbacked_symbols, output_files: &output_files, compile_id_dir: &self.compile_id_dir, qps: TEMPLATE_QUERY_PARAM_SCRIPT, diff --git a/src/templates.rs b/src/templates.rs index 41eecf2..5977a47 100644 --- a/src/templates.rs +++ b/src/templates.rs @@ -376,6 +376,36 @@ pub static TEMPLATE_COMPILATION_METRICS: &str = r#" {{ endfor }} +

Created Symbols

+ + + + + {{ for sym in create_symbols }} + + + + + + + + + {{ endfor }} +
Symbol Value Range Source User stack Framework stack
{sym.symbol}{sym.val}{sym.vr}{sym.source}{sym.user_stack_html | format_unescaped}{sym.stack_html | format_unescaped}
+

Unbacked Symbols

+ + + + + {{ for sym in unbacked_symbols }} + + + + + + + {{ endfor }} +
Symbol Range User stack Framework stack
{sym.symbol}{sym.vr}{sym.user_stack_html | format_unescaped}{sym.stack_html | format_unescaped}
{qps | format_unescaped} diff --git a/src/types.rs b/src/types.rs index 66effb7..bc4b1bf 100644 --- a/src/types.rs +++ b/src/types.rs @@ -20,6 +20,8 @@ pub type SymbolicShapeSpecializationIndex = FxHashMap, Vec>; pub type GuardAddedFastIndex = FxHashMap, Vec>; pub type SymExprInfoIndex = FxHashMap; +pub type CreateSymbolIndex = FxHashMap, Vec>; +pub type UnbackedSymbolIndex = FxHashMap, Vec>; pub type FxIndexMap = IndexMap>; @@ -550,7 +552,7 @@ pub struct SymbolicShapePropagateRealTensorMetadata { pub prefix: Option, } -#[derive(Debug, Deserialize, Serialize)] +#[derive(Debug, Deserialize, Serialize, Clone)] pub struct UnbackedSymbolMetadata { pub symbol: Option, pub node_id: Option, @@ -559,6 +561,16 @@ pub struct UnbackedSymbolMetadata { pub vr: Option, } +#[derive(Debug, Deserialize, Serialize, Clone)] +pub struct CreateSymbolMetadata { + pub symbol: Option, + pub val: Option, + pub vr: Option, + pub source: Option, + pub user_stack: Option, + pub stack: Option, +} + #[derive(Default, Debug, Deserialize, Serialize)] pub struct SymExprInfoMetadata { pub method: Option, @@ -610,6 +622,8 @@ pub struct CompilationMetricsContext<'e> { pub stack_html: String, pub symbolic_shape_specializations: Vec, pub guards_added_fast: Vec, + pub create_symbols: Vec, + pub unbacked_symbols: Vec, pub output_files: &'e Vec, pub compile_id_dir: &'e PathBuf, pub mini_stack_html: String, @@ -757,6 +771,7 @@ pub struct Envelope { pub propagate_real_tensors_provenance: Option, pub guard_added: Option, pub create_unbacked_symbol: Option, + pub create_symbol: Option, pub expression_created: Option, pub missing_fake_kernel: Option, pub mismatched_fake_kernel: Option, @@ -914,6 +929,24 @@ pub struct GuardAddedFastContext { pub stack_html: String, } +#[derive(Debug, Serialize)] +pub struct CreateSymbolContext { + pub symbol: String, + pub val: String, + pub vr: String, + pub source: String, + pub user_stack_html: String, + pub stack_html: String, +} + +#[derive(Debug, Serialize)] +pub struct UnbackedSymbolContext { + pub symbol: String, + pub vr: String, + pub user_stack_html: String, + pub stack_html: String, +} + #[derive(Serialize)] pub struct ProvenanceContext<'a> { pub css: &'a str,