forked from limbo018/DREAMPlace
-
Notifications
You must be signed in to change notification settings - Fork 1
/
draw_place.py
103 lines (97 loc) · 3.09 KB
/
draw_place.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
##
# @file draw_place.py
# @author Yibo Lin
# @date Jan 2019
# @brief Plot placement to an image
#
import os
import sys
import torch
from torch.autograd import Function
#import dreamplace.ops.draw_place.PlaceDrawer as PlaceDrawer
import PlaceDrawer
class DrawPlaceFunction(Function):
@staticmethod
def forward(
pos,
Z,
colmap,
node_size_x, node_size_y,
pin_offset_x, pin_offset_y,
pin2node_map,
xl, yl, xh, yh,
site_width, row_height,
bin_size_x, bin_size_y,
num_movable_nodes, num_filler_nodes,
filename
):
ret = PlaceDrawer.PlaceDrawer.forward(
pos,
Z,
colmap,
node_size_x, node_size_y,
pin_offset_x, pin_offset_y,
pin2node_map,
xl, yl, xh, yh,
site_width, row_height,
bin_size_x, bin_size_y,
num_movable_nodes, num_filler_nodes,
filename
)
return ret
class DrawPlace(object):
"""
@brief Draw placement
"""
def __init__(self, placedb):
"""
@brief initialization
"""
self.node_size_x = torch.from_numpy(placedb.node_size_x)
self.node_size_y = torch.from_numpy(placedb.node_size_y)
self.pin_offset_x = torch.from_numpy(placedb.pin_offset_x)
self.pin_offset_y = torch.from_numpy(placedb.pin_offset_y)
self.pin2node_map = torch.from_numpy(placedb.pin2node_map)
self.xl = placedb.xl
self.yl = placedb.yl
self.xh = placedb.xh
self.yh = placedb.yh
self.site_width = placedb.site_width
self.row_height = placedb.row_height
self.bin_size_x = placedb.bin_size_x
self.bin_size_y = placedb.bin_size_y
self.num_movable_nodes = placedb.num_movable_nodes
self.num_filler_nodes = placedb.num_filler_nodes
def forward(self, pos, Z, colmap, filename):
"""
@param pos cell locations, array of x locations and then y locations
@param filename suffix specifies the format
"""
return DrawPlaceFunction.forward(
pos,
Z,
colmap,
self.node_size_x,
self.node_size_y,
self.pin_offset_x,
self.pin_offset_y,
self.pin2node_map,
self.xl,
self.yl,
self.xh,
self.yh,
self.site_width,
self.row_height,
self.bin_size_x,
self.bin_size_y,
self.num_movable_nodes,
self.num_filler_nodes,
filename
)
def __call__(self, pos, filename):
"""
@brief top API
@param pos cell locations, array of x locations and then y locations
@param filename suffix specifies the format
"""
return self.forward(pos, filename)