Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix multi-layer optimization and broken links #7

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/GAMMA/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ In the basic usage, Gamma will create a map space assuming full flexibility in t
* l2_size: L2 size (Number of elements)
* slevel_min: The minimum number of parallelism
* slevel_max: The maximum number of parallelism. The number of parallelism will be in the range [slevel_min, slevel_max]
* hwconfig: Read in HW configuration from file. An example of hwconfig can be found [here](data/HWconfigs/hw_config.m). An example of using it can be found [here](../run_gamma_with_hwconfig.sh)
* hwconfig: Read in HW configuration from file. An example of hwconfig can be found [here](../../data/HWconfigs/hw_config.m). An example of using it can be found [here](../../run_gamma_with_hwconfig.sh)
* epochs: Number of generation for the optimization
* outdir: The output result directory

Expand Down
2 changes: 1 addition & 1 deletion src/GAMMA/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
parser.add_argument('--offchipBW', type=int, default=-1, help='Off-chip BW')
parser.add_argument('--hwconfig', type=str, default=None, help='HW configuration file')
parser.add_argument('--model', type=str, default="resnet18", help='Model to run')
parser.add_argument('--num_layer', type=int, default=2, help='Number of layers to optimize')
parser.add_argument('--num_layer', type=int, default=0, help='Number of layers to optimize')
parser.add_argument('--singlelayer', type=int, default=0, help='The layer index to optimize')
parser.add_argument('--slevel_min', type=int, default=2, help='Minimum number of parallelization level')
parser.add_argument('--slevel_max', type=int, default=2, help='Maximum number of parallelization level')
Expand Down
19 changes: 13 additions & 6 deletions src/GAMMA/train.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def train_model(model_defs, input_arg, map_cstr=None, chkpt_file='./chkpt'):
l2_size=opt.l2_size, NocBW=opt.NocBW, offchipBW=opt.offchipBW, slevel_min=opt.slevel_min, slevel_max=opt.slevel_max,
fixedCluster=opt.fixedCluster, log_level=opt.log_level, map_cstr=map_cstr)
constraints = {"area":opt.area_budget* 1e6}
chkpt_list = []
for dimension in model_defs:
env.reset_dimension(fitness=fitness, constraints=constraints, dimension=dimension)
env.reset_hw_parm(num_pe=opt.num_pe, l1_size=opt.l1_size, l2_size=opt.l2_size, pe_limit=opt.pe_limit,area_pebuf_only=False, external_area_model=True)
Expand All @@ -87,12 +88,18 @@ def train_model(model_defs, input_arg, map_cstr=None, chkpt_file='./chkpt'):
"L1_size": best_l1_size,
"L2_size": best_l2_size
}
columns = ["runtime", "area", "pe_area_ratio", "PE", "L1_size", "L2_size", "PE_area", "L1_area", "L2_area","best_sol"]
np_array = np.array([chkpt[t] for t in columns[:-1]] + [f'{chkpt["best_sol"]}']).reshape(1, -1)
df = pd.DataFrame(np_array, columns=columns)
df.to_csv(chkpt_file[:-4]+".csv")
with open(chkpt_file, "wb") as fd:
pickle.dump(chkpt, fd)
chkpt_list.append(chkpt)
columns = ["runtime", "area", "pe_area_ratio", "PE", "L1_size", "L2_size", "PE_area", "L1_area", "L2_area","best_sol"]
np_array = None
for chkpt in chkpt_list:
if np_array is None:
np_array = np.array([chkpt[t] for t in columns[:-1]] + [f'{chkpt["best_sol"]}']).reshape(1, -1)
else:
np_array = np.vstack([np_array, np.array([chkpt[t] for t in columns[:-1]] + [f'{chkpt["best_sol"]}']).reshape(1, -1)])
df = pd.DataFrame(np_array, columns=columns)
df.to_csv(chkpt_file[:-4]+".csv")
with open(chkpt_file, "wb") as fd:
pickle.dump(chkpt_list, fd)

def get_cstr_name(mapping_cstr):
if mapping_cstr:
Expand Down