1212
1313
1414class MhaExperiment :
15- WORKLOAD_TEMPLATE = "cascaded_mha.workload_template.yaml"
16- def __init__ (self ):
17- workload_fname = CONFIG_DIR / MhaExperiment .WORKLOAD_TEMPLATE
15+ def __init__ (self , workload_fname ):
16+ self .workload_fname = workload_fname
17+ workload_fname = CONFIG_DIR / workload_fname
18+ self .constraint_config = ''
1819 with open (workload_fname , "r" , encoding = "utf-8" ) as f :
1920 self .workload_template = f .read ()
2021
@@ -26,17 +27,34 @@ def configure_arch(self, arch_fname: str | Path):
2627 with open (arch_fname , "r" ) as f :
2728 self .arch_config = f .read ()
2829
30+ def configure_constraints (self , constraint_fname : str | Path ):
31+ constraint_fname = CONFIG_DIR / constraint_fname
32+ with open (constraint_fname , "r" ) as f :
33+ self .constraint_config = f .read ()
34+
35+ def save_data (self ):
36+ self .data .to_csv (f'{ self .workload_fname } .csv' )
37+
38+ def load_data (self ):
39+ self .data = pd .read_csv (f'{ self .workload_fname } .csv' , index_col = 0 )
40+
2941 def run_experiment (self ):
30- config_str = self .workload_config + "\n " + self .arch_config
42+ config_str = (
43+ self .workload_config + "\n "
44+ + self .arch_config + "\n "
45+ )
3146 config = Config (config_str , "yaml" )
47+
48+ config_str += self .constraint_config
3249 with open (TEST_TMP_DIR / "tmp.yaml" , "w" ) as f :
3350 f .write (config_str )
3451 spec = Specification .from_yaml_files ([TEST_TMP_DIR / "tmp.yaml" ])
52+
3553 result = mapper (config ,
3654 explore_glb_uneven = True ,
3755 spec = spec ,
3856 tmp_path = TEST_TMP_DIR )
39- self .data = explore_fusion (result )
57+ self .data = explore_fusion (result )[[ "__Mappings" , "Offchip_Ac" , "Occupancy" ]]
4058
4159 def plot_ski_slope (self , ** kwargs ):
4260 fig , ax = plot_ski_slope (self .data , ** kwargs )
0 commit comments