Skip to content

Commit

Permalink
Update analysis scripts
Browse files Browse the repository at this point in the history
  • Loading branch information
pblouw committed Sep 16, 2019
1 parent 90ec199 commit 5d20e8b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
2 changes: 2 additions & 0 deletions analysis/analysis.py
Expand Up @@ -27,6 +27,8 @@ def filestring_to_hardware(filestring):
hardware = 'CPU'
elif 'gpu' in filestring:
hardware = 'GPU'
elif 'ncs2' in filestring:
hardware = 'NCS2'
elif 'movidius' in filestring:
hardware = 'MOVIDIUS'
elif 'loihi' in filestring:
Expand Down
19 changes: 11 additions & 8 deletions analysis/summary.py
Expand Up @@ -64,7 +64,7 @@ def set_legend_title(ax):
all_samples = idle_samples + run_samples

dframe = pandas.DataFrame(all_samples)
order = ['CPU', 'GPU', 'JETSON', 'MOVIDIUS', 'LOIHI']
order = ['CPU', 'GPU', 'JETSON', 'NCS2', 'MOVIDIUS', 'LOIHI']

# TABLE 1: Power, energy cost for all hardware devices

Expand All @@ -76,20 +76,21 @@ def set_legend_title(ax):

# compute means over all samples for each hardware device
mean_loihi = joules_dframe.loc[joules_dframe['hardware'] == 'LOIHI'].mean()
mean_ncs2 = joules_dframe.loc[joules_dframe['hardware'] == 'NCS2'].mean()
mean_movidius = joules_dframe.loc[joules_dframe['hardware'] == 'MOVIDIUS'].mean()
mean_jetson = joules_dframe.loc[joules_dframe['hardware'] == 'JETSON'].mean()
mean_cpu = joules_dframe.loc[joules_dframe['hardware'] == 'CPU'].mean()
mean_gpu = joules_dframe.loc[joules_dframe['hardware'] == 'GPU'].mean()

# print out mean values for populating table in summary document
prefixes = ['loihi', 'movidius', 'jetson', 'cpu', 'gpu']
prefixes = ['loihi', 'movidius', 'ncs2', 'jetson', 'cpu', 'gpu']

print('Idle Power')
for prefix in prefixes:
print(prefix + ': %4f' % average_idle_power(idle_samples, prefix))

print('')
means = [mean_loihi, mean_movidius, mean_jetson, mean_cpu, mean_gpu]
means = [mean_loihi, mean_movidius, mean_ncs2, mean_jetson, mean_cpu, mean_gpu]
for data, prefix in zip(means, prefixes):
print(prefix + ':')
print('Total Power: %4f' % data['total_power'])
Expand All @@ -100,6 +101,7 @@ def set_legend_title(ax):

# compute ratios for energy costs for plotting numbers alongside bars
movidius_x = mean_movidius['dynamic_joules_per_inf'] / mean_loihi['dynamic_joules_per_inf']
ncs_x = mean_ncs2['dynamic_joules_per_inf'] / mean_loihi['dynamic_joules_per_inf']
jetson_x = mean_jetson['dynamic_joules_per_inf'] / mean_loihi['dynamic_joules_per_inf']
cpu_x = mean_cpu['dynamic_joules_per_inf'] / mean_loihi['dynamic_joules_per_inf']
gpu_x = mean_gpu['dynamic_joules_per_inf'] / mean_loihi['dynamic_joules_per_inf']
Expand All @@ -110,17 +112,19 @@ def set_legend_title(ax):
plot = sns.barplot(
'hardware', 'dynamic_joules_per_inf',
data=joules_dframe,
order=['LOIHI', 'MOVIDIUS', 'JETSON', 'CPU', 'GPU'])
order=['LOIHI', 'MOVIDIUS', 'NCS2', 'JETSON', 'CPU', 'GPU'])

# add ratios of power consumption to plot
plt.gcf().text(
0.18, 0.17, str(1) + 'x', fontsize=15, fontweight='bold')
plt.gcf().text(
0.33, 0.17, str(round(movidius_x, 1)) + 'x', fontsize=15, fontweight='bold')
0.28, 0.17, str(round(movidius_x, 1)) + 'x', fontsize=15, fontweight='bold')
plt.gcf().text(
0.47, 0.17, str(round(jetson_x, 1)) + 'x', fontsize=15, fontweight='bold')
0.41, 0.17, str(round(ncs_x, 1)) + 'x', fontsize=15, fontweight='bold')
plt.gcf().text(
0.62, 0.17, str(round(cpu_x, 1)) + 'x', fontsize=15, fontweight='bold')
0.52, 0.17, str(round(jetson_x, 1)) + 'x', fontsize=15, fontweight='bold')
plt.gcf().text(
0.65, 0.17, str(round(cpu_x, 1)) + 'x', fontsize=15, fontweight='bold')
plt.gcf().text(
0.77, 0.17, str(round(gpu_x, 1)) + 'x', fontsize=15, fontweight='bold')

Expand All @@ -131,7 +135,6 @@ def set_legend_title(ax):
plot.figure.savefig("./paper/figures/per_inf_comparison.png")
plt.show()


# PLOT 2. Batchsize comparison
fig, ax = plt.subplots(1, 2, figsize=(12, 6))
fig.subplots_adjust(hspace=0.9)
Expand Down
5 changes: 1 addition & 4 deletions models.py
@@ -1,7 +1,7 @@
import string
import warnings
import numpy as np
# import tensorflow as tf
import tensorflow as tf

# attempt to import movidius V1 api, won't work in conda environment
try:
Expand Down Expand Up @@ -34,9 +34,6 @@
input_blob = next(iter(network.inputs))
output_blob = next(iter(network.outputs))

print(network.batch_size)
print(network.precision)

except ImportError:
warnings.warn('NCS OpenVino API not installed', UserWarning)

Expand Down

0 comments on commit 5d20e8b

Please sign in to comment.