xref: /aosp_15_r20/external/pytorch/benchmarks/fuser/plot_speedups.py (revision da0073e96a02ea20f0ac840b70461e3646d07c45)
1import pandas
2
3
4df = pandas.read_csv("perf.csv")
5
6ops = pandas.unique(df["operator"])
7nops = len(ops)
8pivot_op_shape = df.pivot_table(
9    values="time", index=["operator", "shape"], columns=["fuser"]
10)
11pivot_speedups = (pivot_op_shape.T / pivot_op_shape["eager"]).T
12
13import matplotlib.pyplot as plt
14
15
16plt.rcParams["figure.figsize"] = (20, 100)
17fig, axs = plt.subplots(nops)
18plt.subplots_adjust(hspace=0.5)
19for idx, op in enumerate(ops):
20    op_speedups = pivot_speedups.T[op].T
21    op_speedups.plot(ax=axs[idx], kind="bar", ylim=(0, 2), rot=45)
22    axs[idx].set_title(op)
23    axs[idx].set_xlabel("")
24plt.savefig("perf.png")
25