-
Notifications
You must be signed in to change notification settings - Fork 3
/
model.py
37 lines (32 loc) · 1.09 KB
/
model.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
"""
Example of using the class `pytimeloop.app.Model`. This is the default way for
implementing functionality of the `timeloop-model` application.
"""
from pytimeloop.app import Model
from pytimeloop import Config
import glob
import logging
import sys
if __name__ == '__main__':
# Print logs generated by pytimeloop
logger = logging.getLogger('pytimeloop')
formatter = logging.Formatter(
'[%(levelname)s] %(asctime)s - %(name)s - %(message)s')
handler = logging.StreamHandler(sys.stdout)
handler.setFormatter(formatter)
logger.addHandler(handler)
logger.setLevel(logging.INFO)
# Gather configs
prefix = '../tests/timeloop-accelergy-exercises/exercises/timeloop/00-model-conv1d-1level/'
input_files = []
for input_dir in ['arch/', 'map/', 'prob/']:
input_files += glob.glob(prefix + input_dir + '*')
yaml_str = ''
for fname in input_files:
with open(fname, 'r') as f:
yaml_str += f.read()
config = Config.load_yaml(yaml_str)
# Run Model app
app = Model(config, '.')
eval_stats = app.run()
print(eval_stats)