From af762ff7d3c4c19998aa3f06b3cfe4cf6299c614 Mon Sep 17 00:00:00 2001 From: xadupre Date: Tue, 24 Jun 2025 09:46:35 +0200 Subject: [PATCH 1/2] rename command line argument with - --- onnx_diagnostic/_command_lines_parser.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/onnx_diagnostic/_command_lines_parser.py b/onnx_diagnostic/_command_lines_parser.py index 71ca1fd9..58af6aa2 100644 --- a/onnx_diagnostic/_command_lines_parser.py +++ b/onnx_diagnostic/_command_lines_parser.py @@ -734,13 +734,13 @@ def get_parser_agg() -> ArgumentParser: ) parser.add_argument("-v", "--verbose", type=int, default=0, help="verbosity") parser.add_argument( - "--filter_in", + "--filter-in", default="", help="adds a filter to filter in data, syntax is\n" '``":;/:"`` ...', ) parser.add_argument( - "--filter_out", + "--filter-out", default="", help="adds a filter to filter out data, syntax is\n" '``":;/:"`` ...', From ff2f0bbfb804d70ad8e9623a4b6b66ea46573697 Mon Sep 17 00:00:00 2001 From: xadupre Date: Tue, 24 Jun 2025 11:01:58 +0200 Subject: [PATCH 2/2] minor ajustment --- onnx_diagnostic/_command_lines_parser.py | 4 +-- onnx_diagnostic/helpers/log_helper.py | 43 ++++++++++++++++++++---- 2 files changed, 39 insertions(+), 8 deletions(-) diff --git a/onnx_diagnostic/_command_lines_parser.py b/onnx_diagnostic/_command_lines_parser.py index 58af6aa2..5714c053 100644 --- a/onnx_diagnostic/_command_lines_parser.py +++ b/onnx_diagnostic/_command_lines_parser.py @@ -718,13 +718,13 @@ def get_parser_agg() -> ArgumentParser: "peak_gpu_torch,peak_gpu_nvidia,n_node_control_flow," "n_node_constant,n_node_shape,n_node_expand," "n_node_function,n_node_initializer,n_node_scatter," - "time_export_unbiased", + "time_export_unbiased,onnx_n_nodes_no_cst,n_node_initializer_small", help="Columns to compute after the aggregation was done.", ) parser.add_argument( "--views", default="agg-suite,agg-all,disc,speedup,time,time_export,err,cmd," - "bucket-speedup,raw-short,counts,peak-gpu", + "bucket-speedup,raw-short,counts,peak-gpu,onnx", help="Views to add to the output files.", ) parser.add_argument( diff --git a/onnx_diagnostic/helpers/log_helper.py b/onnx_diagnostic/helpers/log_helper.py index f5adf320..55f61a09 100644 --- a/onnx_diagnostic/helpers/log_helper.py +++ b/onnx_diagnostic/helpers/log_helper.py @@ -317,7 +317,7 @@ def apply_excel_style( co: Dict[int, int] = {} sizes: Dict[int, int] = {} cols = set() - for i in range(1, n_rows): + for i in range(1, n_rows + 1): for j, cell in enumerate(sheet[i]): if j > n_cols: break @@ -335,7 +335,7 @@ def apply_excel_style( c = get_column_letter(k) sheet.column_dimensions[c].width = 15 - for i in range(1, n_rows): + for i in range(1, n_rows + 1): for j, cell in enumerate(sheet[i]): if j > n_cols: break @@ -516,13 +516,14 @@ def _to_images_bar( df = self.df.T if self.orientation == "row" else self.df title_suffix = f"\n{title_suffix}" if title_suffix else "" - nn = len(df.columns) // 2 - nn += nn % 2 - fig, axs = plt.subplots(nn, 2, figsize=(12, nn * df.shape[0] / 4)) + n_cols = 3 + nn = df.shape[1] // n_cols + nn += int(df.shape[1] % n_cols != 0) + fig, axs = plt.subplots(nn, n_cols, figsize=(6 * n_cols, nn * df.shape[0] / 5)) pos = 0 imgs = [] for c in self._make_loop(df.columns, verbose): - ax = axs[pos // 2, pos % 2] + ax = axs[pos // n_cols, pos % n_cols] ( df[c].plot.barh(title=f"{c}{title_suffix}", ax=ax) if self.kind == "barh" @@ -1427,9 +1428,11 @@ def __init__( "n_node_scatter", "n_node_function", "n_node_initializer", + "n_node_initializer_small", "n_node_constant", "n_node_shape", "n_node_expand", + "onnx_n_nodes_no_cst", "peak_gpu_torch", "peak_gpu_nvidia", "time_export_unbiased", @@ -1597,6 +1600,9 @@ def first_err(df: pandas.DataFrame) -> pandas.Series: n_node_function=lambda df: gpreserve( df, "onnx_n_functions", gdf(df, "onnx_n_functions") ), + n_node_initializer_small=lambda df: gpreserve( + df, "op_onnx_initializer_small", gdf(df, "op_onnx_initializer_small") + ), n_node_initializer=lambda df: gpreserve( df, "onnx_n_initializer", gdf(df, "onnx_n_initializer") ), @@ -1615,6 +1621,10 @@ def first_err(df: pandas.DataFrame) -> pandas.Series: ), f"Unexpected formula={formula!r}, should be in {sorted(lambdas)}" return lambdas[formula] + if formula == "onnx_n_nodes_no_cst": + return lambda df: gdf(df, "onnx_n_nodes", 0) - gdf( + df, "op_onnx__Constant", 0 + ).fillna(0) if formula == "peak_gpu_torch": return lambda df: gdf(df, "mema_gpu_5_after_export") - gdf(df, "mema_gpu_4_reset") if formula == "peak_gpu_nvidia": @@ -1766,6 +1776,8 @@ def mean_geo(gr): "onnx_weight_size_torch", "onnx_weight_size_proto", "onnx_n_nodes", + "onnx_n_nodes_no_cst", + "op_onnx__Constant", "peak_gpu_torch", "peak_gpu_nvidia", ], @@ -1795,6 +1807,7 @@ def mean_geo(gr): "onnx_weight_size_torch", "onnx_weight_size_proto", "onnx_n_nodes", + "onnx_n_nodes_no_cst", "peak_gpu_torch", "peak_gpu_nvidia", ], @@ -1887,6 +1900,24 @@ def mean_geo(gr): name="cmd", order=order, ), + "onnx": lambda: CubeViewDef( + key_index=index_cols, + values=self._filter_column( + [ + "onnx_filesize", + "onnx_n_nodes", + "onnx_n_nodes_no_cst", + "onnx_weight_size_proto", + "onnx_weight_size_torch", + "op_onnx_initializer_small", + ], + self.values, + ), + ignore_unique=True, + keep_columns_in_index=["suite"], + name="onnx", + order=order, + ), "raw-short": lambda: CubeViewDef( key_index=self.keys_time, values=[c for c in self.values if c not in {"ERR_std", "ERR_stdout"}],