From cc9b5a2e2c9de9b46f2edbbdd26acd9b6eec9e16 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Xavier=20Dupr=C3=A9?= Date: Thu, 14 Sep 2023 00:52:00 +0200 Subject: [PATCH] Update statistics to profiling (#72) * simplify export * add it==0 * it==0 --- _doc/examples/plot_bench_gemm_ort.py | 4 +++- onnx_extended/tools/js_profile.py | 18 +++++++++--------- 2 files changed, 12 insertions(+), 10 deletions(-) diff --git a/_doc/examples/plot_bench_gemm_ort.py b/_doc/examples/plot_bench_gemm_ort.py index 4c32209b..895619db 100644 --- a/_doc/examples/plot_bench_gemm_ort.py +++ b/_doc/examples/plot_bench_gemm_ort.py @@ -473,7 +473,9 @@ def fct_benchmarked(): df = DataFrame(data) df.to_excel("plot_bench_gemm_ort.xlsx") df.to_csv("plot_bench_gemm_ort.csv") -df.drop(["min_exec", "max_exec"], axis=1).to_csv("plot_bench_gemm_ort.csv") +df.drop(["min_exec", "max_exec", "cost_s", "cost"], axis=1).to_csv( + "plot_bench_gemm_ort.csv", index=False +) print(df.head().T) df diff --git a/onnx_extended/tools/js_profile.py b/onnx_extended/tools/js_profile.py index 31c53121..382fcdba 100644 --- a/onnx_extended/tools/js_profile.py +++ b/onnx_extended/tools/js_profile.py @@ -140,13 +140,14 @@ def _preprocess_graph1(df): lambda s: s.replace("ExecutionProvider", "") if isinstance(s, str) else s ) agg_cols = ["dur", "args_op_name", "args_provider"] - if "args_input_type_shape" in df.columns: - agg_cols.append("args_input_type_shape") + for c in ["it==0", "args_input_type_shape"]: + if c in df.columns: + agg_cols.append(c) gr_dur = df[agg_cols].groupby(agg_cols[1:]).sum().sort_values("dur") - gr_n = df[agg_cols].groupby(agg_cols[1:]).count().sort_values("dur") + gr_n = df[agg_cols].groupby(agg_cols[1:]).count() gr_n = gr_n.loc[gr_dur.index, :] gr_n.columns = ["count"] - gr = gr_dur.merge(gr_n, left_index=True, right_index=True) + gr = gr_dur.merge(gr_n, left_index=True, right_index=True, how="outer") gr["ratio"] = gr["dur"] / gr["dur"].sum() return gr_dur, gr_n, gr @@ -159,12 +160,11 @@ def _preprocess_graph2(df): df["args_provider"] = df["args_provider"].apply( lambda s: s.replace("ExecutionProvider", "") if isinstance(s, str) else s ) - df = df[ - (df["it==0"] == 0) & (df["cat"] == "Node") & (df["event_name"] == "kernel_time") - ] + df = df[(df["cat"] == "Node") & (df["event_name"] == "kernel_time")] agg_cols = ["dur", "args_node_index", "args_op_name", "args_provider"] - if "args_input_type_shape" in df.columns: - agg_cols.append("args_input_type_shape") + for c in ["it==0", "args_input_type_shape"]: + if c in df.columns: + agg_cols.append(c) df = df[agg_cols].groupby(agg_cols[1:]).sum() df = df.sort_index(ascending=False) df["ratio"] = df["dur"] / df["dur"].sum()