import pandas as pd
[docs]
class ScalesimReport:
"""
Class which has the utility functions to load report data
"""
def __init__(self):
"""
The constructor method for the class
"""
self.compute_df = pd.DataFrame()
self.bandwidths_df = pd.DataFrame()
self.details_df = pd.DataFrame()
self.compute_df_ready = False
self.bandwidths_df_ready = False
self.details_df_ready = False
#
[docs]
def load_data(self, data_dir='.', run_name=''):
"""
Method to load data of compute, bandwidth and detail reports.
:param data_dir: The folder where the reports are saved
:param run_name: Run name of the simulation specified in the configuration file
:return: Data for compute, bandwidth and detail reports
"""
self.load_compute_report_data(data_dir=data_dir, run_name=run_name)
self.load_bandwidth_report_data(data_dir=data_dir, run_name=run_name)
self.load_detail_report_data(data_dir=data_dir, run_name=run_name)
#
[docs]
def load_compute_report_data(self, data_dir='.', run_name=''):
"""
Method to load data of the compute report.
:param data_dir: The folder where the reports are saved
:param run_name: Run name of the simulation specified in the configuration file
:return: Data of the compute report
"""
csv_filename = data_dir + '/' + run_name + '/COMPUTE_REPORT.csv'
self.compute_df = pd.read_csv(csv_filename, sep=r'\s*,\s*', engine='python')
self.compute_df_ready = True
#
[docs]
def load_bandwidth_report_data(self, data_dir='.', run_name=''):
"""
Method to load data of the bandwidth report.
:param data_dir: The folder where the reports are saved
:param run_name: Run name of the simulation specified in the configuration file
:return: Data of the bandwidth report
"""
csv_filename = data_dir + '/' + run_name + '/BANDWIDTH_REPORT.csv'
self.bandwidths_df = pd.read_csv(csv_filename, sep=r'\s*,\s*', engine='python')
self.bandwidths_df_ready = True
#
[docs]
def load_detail_report_data(self, data_dir='.', run_name=''):
"""
Method to load data of the detail report.
:param data_dir: The folder where the reports are saved
:param run_name: Run name of the simulation specified in the configuration file
:return: Data of the detail report
"""
csv_filename = data_dir + '/' + run_name + '/DETAILED_ACCESS_REPORT.csv'
self.bandwidths_df = pd.read_csv(csv_filename, sep=r'\s*,\s*', engine='python')
self.details_df_ready = True
#
[docs]
def get_total_cycles_single_layer(self, layer_id=0):
"""
Method to get total cycles of a single layer of the workload
:param layer_id: Layer number of the workload
:return: Total cycles of a single layer
"""
assert self.compute_df_ready, 'Data not read yet'
col_name = 'Total Cycles'
elem = self.compute_df[col_name][layer_id]
return elem
#
[docs]
def get_compute_cycles_all_layer(self):
"""
Method to get total cycles of all the layers of the workload
:return: List of total cycles of all the layers
"""
assert self.compute_df_ready, 'Data not read yet'
col_name = 'Total Cycles'
elems = self.compute_df[col_name].to_list()
return elems
#
[docs]
def get_sram_ifmap_reads_single_layer(self, layer_id=0):
"""
Method to get ifmap reads of a single layer of the workload
:param layer_id: Layer number of the workload
:return: Ifmap reads of a single layer
"""
assert self.details_df_ready, 'Data not read yet'
col_name = 'SRAM IFMAP Reads'
elem = self.details_df[col_name][layer_id]
return elem
#
[docs]
def get_sram_ifmap_reads_all_layer(self):
"""
Method to get ifmap reads of all the layers of the workload
:return: List of ifmap reads of all the layers
"""
assert self.details_df_ready, 'Data not read yet'
col_name = 'SRAM IFMAP Reads'
elems = self.details_df[col_name].to_list()
return elems
if __name__ == '__main__':
rpt = ScalesimReport()
rpt.load_data(data_dir='./tutorial1_runs', run_name='scale_sim_tutorial1_64x64_os')
print(rpt.get_compute_cycles_all_layer())
print(rpt.get_total_cycles_single_layer(layer_id=1))