-
Notifications
You must be signed in to change notification settings - Fork 0
/
material_Load_meta.py
54 lines (36 loc) · 1.77 KB
/
material_Load_meta.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
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
import yaml
import numpy as np
''' # Load and return the settings parameter dictionary from file
'''
def LoadMetaData(dir, param_file=''):
with open(r'%s/Experiment_MetaData%s.yaml' % (dir, param_file)) as file:
# MetaData = yaml.full_load(file) # broken with classweight obj load
MetaData = yaml.load(file, Loader=yaml.Loader)
return MetaData
def LoadMaterialMeta(type):
if 'SiM' in type:
raise ValueError("No sim available")
elif 'PiM' in type:
file = 'material.yaml'
#
with open(r'%s' % file) as file:
# MetaData = yaml.full_load(file) # broken with classweight obj load
md = yaml.load(file, Loader=yaml.Loader)
#
# # Deal with SiM Specific alterations
if 'SiM' in type:
if md['network']['mseed'] != 'na':
rng = np.random.default_rng(md['network']['mseed'])
else:
rng = np.random.default_rng()
md['network']['mseeded'] = rng.integers(100000, size=1)[0]
# # Deal with PiM Specific alterations & checks
elif 'PiM' in type:
if len(md['spice']['in_pins']) != (md['network']['num_input']+md['network']['num_config']):
raise ValueError("Number of input voltage pins %d does not match the desired number of input (%d) and config (%d) pins" % (len(md['spice']['in_pins']), md['network']['num_input'], md['network']['num_config']))
if len(md['spice']['out_pins']) != md['network']['num_output']:
raise ValueError("Number of output voltage pins %d does not match the desired number of output netowrk nodes %d" % (len(md['spice']['out_pins']), md['network']['num_output']))
md['network']['num_nodes'] = md['network']['num_input'] + md['network']['num_config'] + md['network']['num_output']
return md
#
# fin