In [6]:
import pickle
import pandas as pd
import tabulate
In [2]:
def pickle_load(path):
with open(path, 'rb') as f:
return pickle.load(f)
def load(t3f_cpu_path, t3f_gpu_path, ttpy_path=None):
cpu = pickle_load(t3f_cpu_path)
gpu = pickle_load(t3f_gpu_path)
d = {}
op_list = ['matvec', 'matmul', 'norm', 'round', 'gram', 'project_rank100']
one_cpu = []
for op in op_list:
if op == 'gram':
# Single element Gram matrix is flat inner.
curr_time = cpu['flatinner']['wall_time'] * 1000
else:
curr_time = cpu[op]['wall_time'] * 1000
one_cpu.append(curr_time)
d['one on CPU'] = one_cpu
one_gpu = []
for op in op_list:
if op == 'gram':
# Single element Gram matrix is flat inner.
curr_time = gpu['flatinner']['wall_time'] * 1000
else:
curr_time = gpu[op]['wall_time'] * 1000
one_gpu.append(curr_time)
d['one on GPU'] = one_gpu
batch_cpu = []
for op in op_list:
if op == 'gram':
curr_time = cpu['batch_gram']['wall_time'] * 1000 / 100**2
else:
curr_time = cpu['batch_' + op]['wall_time'] * 1000 / 100
batch_cpu.append(curr_time)
d['batch on CPU'] = batch_cpu
batch_gpu = []
for op in op_list:
if op == 'gram':
curr_time = gpu['batch_gram']['wall_time'] * 1000 / 100.**2
else:
curr_time = gpu['batch_' + op]['wall_time'] * 1000 / 100.
# curr_time = gpu['batch_' + op + '_time'] * 1000
batch_gpu.append(curr_time)
d['batch on GPU'] = batch_gpu
if ttpy_path:
ttpy = pickle_load(ttpy_path)
ttpy_col = []
for op in op_list:
if op == 'gram':
# Single element Gram matrix is flat inner.
curr_time = ttpy['flatinner_time'] * 1000
else:
curr_time = ttpy[op + '_time'] * 1000
ttpy_col.append(curr_time)
d['ttpy, one on CPU'] = ttpy_col
df = pd.DataFrame(d, index=op_list)
regime_list = ['one on CPU', 'one on GPU', 'batch on CPU', 'batch on GPU']
if ttpy_path:
regime_list = ['ttpy, one on CPU'] + regime_list
df = df[regime_list]
return df
In [3]:
df = load('logs_cpu.pkl', 'logs_gpu.pkl', ttpy_path='logs_ttpy.pkl')
In [4]:
df.round(decimals=3)
Out[4]:
In [5]:
print(df.round(decimals=3).to_latex())
In [10]:
print(tabulate.tabulate(df.round(decimals=3), headers=df.keys(), tablefmt="rst"))
In [ ]: