-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot_cpu.py
More file actions
76 lines (65 loc) · 2.21 KB
/
Copy pathplot_cpu.py
File metadata and controls
76 lines (65 loc) · 2.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import numpy as np
import matplotlib.pyplot as plt
import matplotlib.ticker as ticker
# Data organization
configs = [
"Ti, Pyr.", "S, Pyr.", "M, Pyr.", "B, Pyr.",
"Ti, Iso.", "S, Iso.", "B, Iso."
]
N_values = [256, 512, 1024, 2048, 4096]
data = np.array([
[0.950849, 0.987486, 0.989155, 0.990131, 0.997716], # Ti, Pyr.
[0.941655, 0.970678, 0.986227, 0.983855, 0.99496], # S, Pyr.
[0.90779, 0.964782, 0.976409, 0.981987, 0.993324], # M, Pyr.
[0.899912, 0.94694, 0.95224, 0.966231, 0.992633], # B, Pyr.
[0.922873, 0.956576, 0.974857, 0.972628, 0.990712], # Ti, Iso.
[0.822407, 0.841416, 0.942377, 0.962056, 0.984504], # S, Iso.
[0.883495, 0.886366, 0.891059, 0.92211, 0.947521] # B, Iso.
])
# Plot configuration
plt.figure(figsize=(14, 8))
ax = plt.gca()
# Style definitions
colors = {'Ti': '#E41A1C', 'S': '#4DAF4A', 'M': '#377EB8', 'B': '#984EA3'}
markers = {'Pyr.': 'o', 'Iso.': 's'}
linestyles = {'Pyr.': '-', 'Iso.': '--'}
# Plot each configuration
for i, config in enumerate(configs):
size, pyramid_type = map(str.strip, config.split(','))
y = data[i]
mask = ~np.isnan(y)
x = np.array(N_values)[mask]
y = y[mask]
ax.plot(
x, y,
color=colors[size],
marker=markers[pyramid_type],
linestyle=linestyles[pyramid_type],
linewidth=2.5,
markersize=10,
label=config
)
# Axis formatting
ax.set_xscale('log', base=2)
ax.set_xticks(N_values)
ax.get_xaxis().set_major_formatter(ticker.ScalarFormatter())
ax.tick_params(axis='both', which='major', labelsize=17)
ax.grid(True, linestyle='--', alpha=0.7)
# Labels and title
# Labels and title
ax.set_title("Graph Construction Runtime Proportion for ViG on CPU", fontsize=25, pad=15)
ax.set_xlabel("Image Resolution (Height=Width)", fontsize=20, labelpad=10)
ax.set_ylabel("Runtime Proportion", fontsize=20, labelpad=10)
# Legend
handles, labels = ax.get_legend_handles_labels()
ax.legend(
handles, labels,
fontsize=15,
title="Variants",
title_fontsize=17,
loc='upper left',
bbox_to_anchor=(1, 1)
)
plt.tight_layout(rect=[0, 0, 0.85, 1]) # Make space for legend
plt.savefig('cpu_vig_profile.pdf', dpi=300, bbox_inches='tight')
plt.show()