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
import os
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
sns.set_theme()
if __name__ == "__main__":
df = pd.read_csv("simple.csv")
# The headers of the CSV are: design,resource,simple,complete,ratio
# Group data using "resource"
grouped_data = df.groupby("resource")
# Mapping to rename the design names
design_mapping = {
"vgg": "VGG",
"alex": "AlexNet",
"google": "GoogleNet",
"squeeze": "SqueezeNet",
"mobile": "MobileNet",
"lenet": "LeNet",
}
# Replace the design names with the mapping
df["design"] = df["design"].map(design_mapping)
# For each group, create a bar plot
for resource, data in grouped_data:
plt.figure()
print(data)
# Cut the data to only include the relevant columns: design and ration
ax = sns.barplot(x="design", y="ratio", data=data, errorbar=None)
# Add a dotted line at y=1
ax.axhline(1, color="black", linewidth=1, linestyle="--")
# X-axis is "Neural Network" and Y-axis is "Resource Usage Ratio"
ax.set(xlabel="Neural Network", ylabel="Usage Ratio")
# Tilt the x-axis labels
plt.xticks(rotation=20)
if resource == "lut":
title = "LUT"
else:
title = "Register"
ax.set(title=f"""{title} Usage""")
# Save this ax into a file
plt.savefig(f"""{resource}_usage.pdf""", bbox_inches="tight")