Skip to content

Commit

Permalink
Update statistics to profiling (#72)
Browse files Browse the repository at this point in the history
* simplify export

* add it==0

* it==0
  • Loading branch information
xadupre authored Sep 13, 2023
1 parent a76b74d commit cc9b5a2
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 10 deletions.
4 changes: 3 additions & 1 deletion _doc/examples/plot_bench_gemm_ort.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 9 additions & 9 deletions onnx_extended/tools/js_profile.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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()
Expand Down

0 comments on commit cc9b5a2

Please sign in to comment.