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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import glob
|
| 2 |
+
import os
|
| 3 |
+
import re
|
| 4 |
+
import datasets
|
| 5 |
+
import io
|
| 6 |
+
import math
|
| 7 |
+
import pandas as pd
|
| 8 |
+
import numpy as np
|
| 9 |
+
from numpy import genfromtxt
|
| 10 |
+
|
| 11 |
+
from requests import get
|
| 12 |
+
|
| 13 |
+
#datasets.logging.set_verbosity_debug()
|
| 14 |
+
#logger = datasets.logging.get_logger(__name__)
|
| 15 |
+
#datasets.logging.set_verbosity_info()
|
| 16 |
+
#datasets.logging.set_verbosity_debug()
|
| 17 |
+
|
| 18 |
+
_REPO = "https://huggingface.co/datasets/jason122490/2023_ICCAD_ProblemC/resolve/main"
|
| 19 |
+
|
| 20 |
+
_URLS = {
|
| 21 |
+
"fake_data_url": f"{_REPO}/fake-circuit-data.zip",
|
| 22 |
+
"real_data_url": f"{_REPO}/real-circuit-data.zip",
|
| 23 |
+
}
|
| 24 |
+
|
| 25 |
+
|
| 26 |
+
class ICCAD_Dataset(datasets.GeneratorBasedBuilder):
|
| 27 |
+
def _info(self):
|
| 28 |
+
features = datasets.Features({
|
| 29 |
+
"data_idx": datasets.Value("string"),
|
| 30 |
+
"current": datasets.Image(),
|
| 31 |
+
"pdn_density": datasets.Image(),
|
| 32 |
+
"eff_dist": datasets.Image(),
|
| 33 |
+
"ir_drop": datasets.Image(),
|
| 34 |
+
"netlist": datasets.Value("string"),
|
| 35 |
+
"R_map_11": datasets.Image(),
|
| 36 |
+
"R_map_14": datasets.Image(),
|
| 37 |
+
"R_map_44": datasets.Image(),
|
| 38 |
+
"R_map_47": datasets.Image(),
|
| 39 |
+
"R_map_77": datasets.Image(),
|
| 40 |
+
"R_map_78": datasets.Image(),
|
| 41 |
+
"R_map_88": datasets.Image(),
|
| 42 |
+
"R_map_89": datasets.Image(),
|
| 43 |
+
"R_map_99": datasets.Image(),
|
| 44 |
+
"I_map": datasets.Image(),
|
| 45 |
+
})
|
| 46 |
+
|
| 47 |
+
return datasets.DatasetInfo(
|
| 48 |
+
features=features,
|
| 49 |
+
)
|
| 50 |
+
|
| 51 |
+
|
| 52 |
+
def _split_generators(self, dl_manager):
|
| 53 |
+
fake_idx = []
|
| 54 |
+
fake_cur = []
|
| 55 |
+
fake_pdn = []
|
| 56 |
+
fake_dist = []
|
| 57 |
+
fake_irdrop = []
|
| 58 |
+
fake_netlist = []
|
| 59 |
+
|
| 60 |
+
real_idx = []
|
| 61 |
+
real_cur = []
|
| 62 |
+
real_pdn = []
|
| 63 |
+
real_dist = []
|
| 64 |
+
real_irdrop = []
|
| 65 |
+
real_netlist = []
|
| 66 |
+
|
| 67 |
+
|
| 68 |
+
# Download images
|
| 69 |
+
fake_data_files = os.path.join(dl_manager.download_and_extract(_URLS["fake_data_url"]), "fake-circuit-data") # skip _MACOSX dir
|
| 70 |
+
real_data_files = os.path.join(dl_manager.download_and_extract(_URLS["real_data_url"]), "real-circuit-data") # skip _MACOSX dir
|
| 71 |
+
#logger.info(f"text_data_files: {text_data_files}")
|
| 72 |
+
#logger.info(f"text_data_files: {text_data_files[10]}")
|
| 73 |
+
|
| 74 |
+
fake_path_files = sorted(glob.glob(os.path.join(fake_data_files, "*.sp")))
|
| 75 |
+
real_path_files = sorted(glob.glob(os.path.join(real_data_files, "*")))
|
| 76 |
+
|
| 77 |
+
# for fake
|
| 78 |
+
for path in fake_path_files:
|
| 79 |
+
data_idx = os.path.basename(path).split(".")[0]
|
| 80 |
+
fake_idx.append(data_idx)
|
| 81 |
+
data_path = glob.glob(os.path.join(os.path.dirname(path), data_idx + "*.*"))
|
| 82 |
+
|
| 83 |
+
for data in data_path:
|
| 84 |
+
if "current.csv" in os.path.basename(data):
|
| 85 |
+
fake_cur.append(data)
|
| 86 |
+
elif "eff_dist.csv" in os.path.basename(data):
|
| 87 |
+
fake_dist.append(data)
|
| 88 |
+
elif "ir_drop_map.csv" in os.path.basename(data):
|
| 89 |
+
fake_irdrop.append(data)
|
| 90 |
+
elif "pdn_density.csv" in os.path.basename(data):
|
| 91 |
+
fake_pdn.append(data)
|
| 92 |
+
elif ".sp" in os.path.basename(data):
|
| 93 |
+
fake_netlist.append(data)
|
| 94 |
+
else:
|
| 95 |
+
raise AssertionError('fake data path error')
|
| 96 |
+
|
| 97 |
+
assert len(fake_idx) == len(fake_cur) == len(fake_dist) == len(fake_irdrop) == len(fake_pdn) == len(fake_netlist), f'{(len(fake_idx), len(fake_cur), len(fake_dist), len(fake_irdrop), len(fake_pdn), len(fake_netlist))} fake data length not the same'
|
| 98 |
+
|
| 99 |
+
# for real
|
| 100 |
+
for path in real_path_files:
|
| 101 |
+
data_idx = os.path.basename(path)
|
| 102 |
+
real_idx.append(data_idx)
|
| 103 |
+
data_path = glob.glob(os.path.join(path, "*.*"))
|
| 104 |
+
|
| 105 |
+
for data in data_path:
|
| 106 |
+
if "current_map.csv" in os.path.basename(data):
|
| 107 |
+
real_cur.append(data)
|
| 108 |
+
elif "eff_dist_map.csv" in os.path.basename(data):
|
| 109 |
+
real_dist.append(data)
|
| 110 |
+
elif "ir_drop_map.csv" in os.path.basename(data):
|
| 111 |
+
real_irdrop.append(data)
|
| 112 |
+
elif "pdn_density.csv" in os.path.basename(data):
|
| 113 |
+
real_pdn.append(data)
|
| 114 |
+
elif "netlist.sp" in os.path.basename(data):
|
| 115 |
+
real_netlist.append(data)
|
| 116 |
+
else:
|
| 117 |
+
raise AssertionError('real data path error')
|
| 118 |
+
|
| 119 |
+
assert len(real_idx) == len(real_cur) == len(real_dist) == len(real_irdrop) == len(real_pdn) == len(real_netlist), f'{(len(real_idx), len(real_cur), len(real_dist), len(real_irdrop), len(real_pdn), len(real_netlist))} real data length not the same'
|
| 120 |
+
|
| 121 |
+
return [
|
| 122 |
+
datasets.SplitGenerator(
|
| 123 |
+
name=datasets.Split('fake'),
|
| 124 |
+
gen_kwargs={
|
| 125 |
+
"data_idx": fake_idx,
|
| 126 |
+
"current": fake_cur,
|
| 127 |
+
"pdn_density": fake_pdn,
|
| 128 |
+
"eff_dist": fake_dist,
|
| 129 |
+
"ir_drop": fake_irdrop,
|
| 130 |
+
"netlist": fake_netlist,
|
| 131 |
+
},
|
| 132 |
+
),
|
| 133 |
+
datasets.SplitGenerator(
|
| 134 |
+
name=datasets.Split('real'),
|
| 135 |
+
gen_kwargs={
|
| 136 |
+
"data_idx": real_idx,
|
| 137 |
+
"current": real_cur,
|
| 138 |
+
"pdn_density": real_pdn,
|
| 139 |
+
"eff_dist": real_dist,
|
| 140 |
+
"ir_drop": real_irdrop,
|
| 141 |
+
"netlist": real_netlist,
|
| 142 |
+
},
|
| 143 |
+
),
|
| 144 |
+
]
|
| 145 |
+
|
| 146 |
+
|
| 147 |
+
def _generate_examples(self, data_idx, current, pdn_density, eff_dist, ir_drop, netlist):
|
| 148 |
+
for i, (_data_idx, _current, _pdn_density, _eff_dist, _ir_drop, _netlist) in enumerate(zip(data_idx, current, pdn_density, eff_dist, ir_drop, netlist)):
|
| 149 |
+
|
| 150 |
+
netlist = open(_netlist, 'r').read()
|
| 151 |
+
H, W = genfromtxt(_current, delimiter=',').shape
|
| 152 |
+
H, W = H + 1, W + 1
|
| 153 |
+
|
| 154 |
+
df = pd.read_csv(io.StringIO(netlist), sep = " ", names = ['type', 'n1', 'n2', 'values', 'tmp'])
|
| 155 |
+
df = df.drop(columns='tmp')
|
| 156 |
+
df = df.astype({'type': 'str', 'n1':'str', 'n2': 'str', 'values': 'float'})
|
| 157 |
+
df[['n1', 'm1', 'x1', 'y1']] = df['n1'].str.split('_', expand=True)
|
| 158 |
+
df[['n2', 'm2', 'x2', 'y2']] = df['n2'].str.split('_', expand=True)
|
| 159 |
+
df['m1'] = df['m1'].str.replace('m', '')
|
| 160 |
+
df['m2'] = df['m2'].str.replace('m', '')
|
| 161 |
+
df = df.drop(columns=['n1', 'n2'])
|
| 162 |
+
|
| 163 |
+
# R
|
| 164 |
+
df_R = df[df['type'].str.contains('R')]
|
| 165 |
+
df_R[['m1', 'm2']] = df_R[['m1', 'm2']].astype(int)
|
| 166 |
+
df_R[['x1', 'y1', 'x2', 'y2']] = df_R[['x1', 'y1', 'x2', 'y2']].astype(float) / 2000 + 0.5
|
| 167 |
+
|
| 168 |
+
# m1
|
| 169 |
+
R_map_11 = np.zeros((H, W))
|
| 170 |
+
R_map_14 = np.zeros((H, W))
|
| 171 |
+
R_map_44 = np.zeros((H, W))
|
| 172 |
+
R_map_47 = np.zeros((H, W))
|
| 173 |
+
R_map_77 = np.zeros((H, W))
|
| 174 |
+
R_map_78 = np.zeros((H, W))
|
| 175 |
+
R_map_88 = np.zeros((H, W))
|
| 176 |
+
R_map_89 = np.zeros((H, W))
|
| 177 |
+
R_map_99 = np.zeros((H, W))
|
| 178 |
+
|
| 179 |
+
for index, row in df_R.iterrows():
|
| 180 |
+
# m1 -> m1
|
| 181 |
+
if row['m1'] == 1 and row['m2'] == 1:
|
| 182 |
+
# H line
|
| 183 |
+
if row['x1'] != row['x2']:
|
| 184 |
+
y = int(row['y1'])
|
| 185 |
+
if row['x1'] < row['x2']:
|
| 186 |
+
for x in range(int(row['x1']), int(math.ceil(row['x2']))):
|
| 187 |
+
R_map_11[x][y] += row['values'] / (row['x2'] - row['x1'])
|
| 188 |
+
else:
|
| 189 |
+
for x in range(int(row['x2']), int(math.ceil(row['x1']))):
|
| 190 |
+
R_map_11[x][y] += row['values'] / (row['x1'] - row['x2'])
|
| 191 |
+
|
| 192 |
+
# V line
|
| 193 |
+
elif row['y1'] != row['y2']:
|
| 194 |
+
x = int(row['x1'])
|
| 195 |
+
if row['y1'] < row['y2']:
|
| 196 |
+
for y in range(int(row['y1']), int(math.ceil(row['y2']))):
|
| 197 |
+
R_map_11[x][y] += row['values'] / (row['y2'] - row['y1'])
|
| 198 |
+
else:
|
| 199 |
+
for x in range(int(row['y2']), int(math.ceil(row['y1']))):
|
| 200 |
+
R_map_11[x][y] += row['values'] / (row['y1'] - row['y2'])
|
| 201 |
+
else:
|
| 202 |
+
raise AssertionError('R map row error')
|
| 203 |
+
|
| 204 |
+
# m1 -> m4
|
| 205 |
+
elif row['m1'] == 1 and row['m2'] == 4:
|
| 206 |
+
# Via
|
| 207 |
+
if row['x1'] == row['x2'] and row['y1'] == row['y2']:
|
| 208 |
+
y = int(row['y1'])
|
| 209 |
+
x = int(row['x1'])
|
| 210 |
+
R_map_14[x][y] += row['values']
|
| 211 |
+
else:
|
| 212 |
+
raise AssertionError('R map row error')
|
| 213 |
+
|
| 214 |
+
# m4 -> m4
|
| 215 |
+
elif row['m1'] == 4 and row['m2'] == 4:
|
| 216 |
+
# H line
|
| 217 |
+
if row['x1'] != row['x2']:
|
| 218 |
+
y = int(row['y1'])
|
| 219 |
+
if row['x1'] < row['x2']:
|
| 220 |
+
for x in range(int(row['x1']), int(math.ceil(row['x2']))):
|
| 221 |
+
R_map_44[x][y] += row['values'] / (row['x2'] - row['x1'])
|
| 222 |
+
else:
|
| 223 |
+
for x in range(int(row['x2']), int(math.ceil(row['x1']))):
|
| 224 |
+
R_map_44[x][y] += row['values'] / (row['x1'] - row['x2'])
|
| 225 |
+
|
| 226 |
+
# V line
|
| 227 |
+
elif row['y1'] != row['y2']:
|
| 228 |
+
x = int(row['x1'])
|
| 229 |
+
if row['y1'] < row['y2']:
|
| 230 |
+
for y in range(int(row['y1']), int(math.ceil(row['y2']))):
|
| 231 |
+
R_map_44[x][y] += row['values'] / (row['y2'] - row['y1'])
|
| 232 |
+
else:
|
| 233 |
+
for x in range(int(row['y2']), int(math.ceil(row['y1']))):
|
| 234 |
+
R_map_44[x][y] += row['values'] / (row['y1'] - row['y2'])
|
| 235 |
+
else:
|
| 236 |
+
raise AssertionError('R map row error')
|
| 237 |
+
|
| 238 |
+
# m4 -> m7
|
| 239 |
+
elif row['m1'] == 4 and row['m2'] == 7:
|
| 240 |
+
# Via
|
| 241 |
+
if row['x1'] == row['x2'] and row['y1'] == row['y2']:
|
| 242 |
+
y = int(row['y1'])
|
| 243 |
+
x = int(row['x1'])
|
| 244 |
+
R_map_47[x][y] += row['values']
|
| 245 |
+
else:
|
| 246 |
+
raise AssertionError('R map row error')
|
| 247 |
+
|
| 248 |
+
# m7 -> m7
|
| 249 |
+
elif row['m1'] == 7 and row['m2'] == 7:
|
| 250 |
+
# H line
|
| 251 |
+
if row['x1'] != row['x2']:
|
| 252 |
+
y = int(row['y1'])
|
| 253 |
+
if row['x1'] < row['x2']:
|
| 254 |
+
for x in range(int(row['x1']), int(math.ceil(row['x2']))):
|
| 255 |
+
R_map_77[x][y] += row['values'] / (row['x2'] - row['x1'])
|
| 256 |
+
else:
|
| 257 |
+
for x in range(int(row['x2']), int(math.ceil(row['x1']))):
|
| 258 |
+
R_map_77[x][y] += row['values'] / (row['x1'] - row['x2'])
|
| 259 |
+
|
| 260 |
+
# V line
|
| 261 |
+
elif row['y1'] != row['y2']:
|
| 262 |
+
x = int(row['x1'])
|
| 263 |
+
if row['y1'] < row['y2']:
|
| 264 |
+
for y in range(int(row['y1']), int(math.ceil(row['y2']))):
|
| 265 |
+
R_map_77[x][y] += row['values'] / (row['y2'] - row['y1'])
|
| 266 |
+
else:
|
| 267 |
+
for x in range(int(row['y2']), int(math.ceil(row['y1']))):
|
| 268 |
+
R_map_77[x][y] += row['values'] / (row['y1'] - row['y2'])
|
| 269 |
+
else:
|
| 270 |
+
raise AssertionError('R map row error')
|
| 271 |
+
|
| 272 |
+
# m7 -> m8
|
| 273 |
+
elif row['m1'] == 7 and row['m2'] == 8:
|
| 274 |
+
# Via
|
| 275 |
+
if row['x1'] == row['x2'] and row['y1'] == row['y2']:
|
| 276 |
+
y = int(row['y1'])
|
| 277 |
+
x = int(row['x1'])
|
| 278 |
+
R_map_78[x][y] += row['values']
|
| 279 |
+
else:
|
| 280 |
+
raise AssertionError('R map row error')
|
| 281 |
+
|
| 282 |
+
# m8 -> m8
|
| 283 |
+
elif row['m1'] == 8 and row['m2'] == 8:
|
| 284 |
+
# H line
|
| 285 |
+
if row['x1'] != row['x2']:
|
| 286 |
+
y = int(row['y1'])
|
| 287 |
+
if row['x1'] < row['x2']:
|
| 288 |
+
for x in range(int(row['x1']), int(math.ceil(row['x2']))):
|
| 289 |
+
R_map_88[x][y] += row['values'] / (row['x2'] - row['x1'])
|
| 290 |
+
else:
|
| 291 |
+
for x in range(int(row['x2']), int(math.ceil(row['x1']))):
|
| 292 |
+
R_map_88[x][y] += row['values'] / (row['x1'] - row['x2'])
|
| 293 |
+
|
| 294 |
+
# V line
|
| 295 |
+
elif row['y1'] != row['y2']:
|
| 296 |
+
x = int(row['x1'])
|
| 297 |
+
if row['y1'] < row['y2']:
|
| 298 |
+
for y in range(int(row['y1']), int(math.ceil(row['y2']))):
|
| 299 |
+
R_map_88[x][y] += row['values'] / (row['y2'] - row['y1'])
|
| 300 |
+
else:
|
| 301 |
+
for x in range(int(row['y2']), int(math.ceil(row['y1']))):
|
| 302 |
+
R_map_88[x][y] += row['values'] / (row['y1'] - row['y2'])
|
| 303 |
+
else:
|
| 304 |
+
raise AssertionError('R map row error')
|
| 305 |
+
|
| 306 |
+
# m8 -> m9
|
| 307 |
+
elif row['m1'] == 8 and row['m2'] == 9:
|
| 308 |
+
# Via
|
| 309 |
+
if row['x1'] == row['x2'] and row['y1'] == row['y2']:
|
| 310 |
+
y = int(row['y1'])
|
| 311 |
+
x = int(row['x1'])
|
| 312 |
+
R_map_89[x][y] += row['values']
|
| 313 |
+
else:
|
| 314 |
+
raise AssertionError('R map row error')
|
| 315 |
+
|
| 316 |
+
# m9 -> m9
|
| 317 |
+
elif row['m1'] == 9 and row['m2'] == 9:
|
| 318 |
+
# H line
|
| 319 |
+
if row['x1'] != row['x2']:
|
| 320 |
+
y = int(row['y1'])
|
| 321 |
+
if row['x1'] < row['x2']:
|
| 322 |
+
for x in range(int(row['x1']), int(math.ceil(row['x2']))):
|
| 323 |
+
R_map_99[x][y] += row['values'] / (row['x2'] - row['x1'])
|
| 324 |
+
else:
|
| 325 |
+
for x in range(int(row['x2']), int(math.ceil(row['x1']))):
|
| 326 |
+
R_map_99[x][y] += row['values'] / (row['x1'] - row['x2'])
|
| 327 |
+
|
| 328 |
+
# V line
|
| 329 |
+
elif row['y1'] != row['y2']:
|
| 330 |
+
x = int(row['x1'])
|
| 331 |
+
if row['y1'] < row['y2']:
|
| 332 |
+
for y in range(int(row['y1']), int(math.ceil(row['y2']))):
|
| 333 |
+
R_map_99[x][y] += row['values'] / (row['y2'] - row['y1'])
|
| 334 |
+
else:
|
| 335 |
+
for x in range(int(row['y2']), int(math.ceil(row['y1']))):
|
| 336 |
+
R_map_99[x][y] += row['values'] / (row['y1'] - row['y2'])
|
| 337 |
+
else:
|
| 338 |
+
raise AssertionError('R map row error')
|
| 339 |
+
else:
|
| 340 |
+
raise AssertionError('R map layer not found', row['m1'], row['m2'])
|
| 341 |
+
|
| 342 |
+
# I
|
| 343 |
+
df_I = df[df['type'].str.contains('I')]
|
| 344 |
+
df_I[['x1', 'y1']] = df_I[['x1', 'y1']].astype(float) / 2000 + 0.5
|
| 345 |
+
|
| 346 |
+
I_map = np.zeros((H, W))
|
| 347 |
+
|
| 348 |
+
for index, row in df_I.iterrows():
|
| 349 |
+
y = int(row['y1'])
|
| 350 |
+
x = int(row['x1'])
|
| 351 |
+
I_map[x][y] += row['values']
|
| 352 |
+
|
| 353 |
+
|
| 354 |
+
|
| 355 |
+
yield i, {
|
| 356 |
+
"data_idx": _data_idx,
|
| 357 |
+
"current": genfromtxt(_current, delimiter=',') * 1e6,
|
| 358 |
+
"pdn_density": genfromtxt(_pdn_density, delimiter=','),
|
| 359 |
+
"eff_dist": genfromtxt(_eff_dist, delimiter=','),
|
| 360 |
+
"ir_drop": genfromtxt(_ir_drop, delimiter=',') * 1e3,
|
| 361 |
+
"netlist": open(_netlist, 'r').read(),
|
| 362 |
+
"R_map_11": R_map_11,
|
| 363 |
+
"R_map_14": R_map_14,
|
| 364 |
+
"R_map_44": R_map_44,
|
| 365 |
+
"R_map_47": R_map_47,
|
| 366 |
+
"R_map_77": R_map_77,
|
| 367 |
+
"R_map_78": R_map_78,
|
| 368 |
+
"R_map_88": R_map_88,
|
| 369 |
+
"R_map_89": R_map_89,
|
| 370 |
+
"R_map_99": R_map_99,
|
| 371 |
+
"I_map": I_map * 1e6,
|
| 372 |
+
}
|
fake-circuit-data.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:916dc46f9c1a6c777d28ccd8ab58f141ac6b8344578f43e492c26e2f55d3f397
|
| 3 |
+
size 564496028
|
real-circuit-data.zip
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:703036743254e126985aaa44dd38073319b4c1de2c739b7282bc32c7997b40f4
|
| 3 |
+
size 43261968
|