Skip to content

Commit 6175eb6

Browse files
initialize structure to support fixed script #3
1 parent c39d8c7 commit 6175eb6

File tree

3 files changed

+31
-3
lines changed

3 files changed

+31
-3
lines changed

.vscode/settings.json

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
{
2+
"python.pythonPath": ".venv/bin/python"
3+
}

drills.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313
import numpy as np
1414
import time
1515
from drills.model import A2C
16+
from drills.fixed_optimization import optimize_with_fixed_script
1617
from pyfiglet import Figlet
1718

1819
def log(message):
@@ -29,8 +30,12 @@ def add_usage(self, usage, actions, groups, prefix=None):
2930
description='Performs logic synthesis optimization using RL')
3031
parser._positionals.title = 'Positional arguments'
3132
parser._optionals.title = 'Optional arguments'
32-
parser.add_argument('-v', '--version', action='version', version = 'DRiLLS v0.1', help = "Shows program's version number and exit")
33-
parser.add_argument("-l", "--load_model", action='store_true', help="Loads a saved Tensorflow model")
33+
parser.add_argument('-v', '--version', action='version', \
34+
version = 'DRiLLS v0.1', help="Shows program's version number and exit")
35+
parser.add_argument("-l", "--load_model", action='store_true', \
36+
help="Loads a saved Tensorflow model")
37+
parser.add_argument("-s", "--fixed_script", type=open, \
38+
help="Executes a fixed optimization script before DRiLLS")
3439
parser.add_argument("mode", type=str, choices=['train', 'optimize'], \
3540
help="Use the design to train the model or only optimize it")
3641
parser.add_argument("mapping", type=str, choices=['scl', 'fpga'], \
@@ -44,6 +49,9 @@ def add_usage(self, usage, actions, groups, prefix=None):
4449
f = Figlet(font='slant')
4550
print(f.renderText('DRiLLS'))
4651

52+
if args.fixed_script:
53+
params = optimize_with_fixed_script(params, args.fixed_script)
54+
4755
if args.mapping == 'scl':
4856
fpga_mapping = False
4957
else:
@@ -72,5 +80,5 @@ def add_usage(self, usage, actions, groups, prefix=None):
7280
log('Starting agent to optimize')
7381
learner = A2C(options, load_model=True)
7482
for _ in range(options['iterations']):
75-
# to be completed
83+
# TODO: iteratively run the optimizer
7684
pass

drills/fixed_optimization.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/usr/bin/python3
2+
3+
# Copyright (c) 2019, SCALE Lab, Brown University
4+
# All rights reserved.
5+
6+
# This source code is licensed under the BSD-style license found in the
7+
# LICENSE file in the root directory of this source tree.
8+
9+
def optimize_with_fixed_script(params, fixed_script_file):
10+
"""
11+
Optimizes the design with the fixed script and writes down a new design file
12+
"""
13+
optimized_design_file = None
14+
# TODO: run an scl session with the fixed script.
15+
16+
params.design_file = optimized_design_file
17+
return params

0 commit comments

Comments
 (0)