Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
watcag-public
fpga-syspart
Commits
094d8523
Commit
094d8523
authored
Nov 01, 2020
by
justinborromeo
Browse files
WIP
parent
65e0c008
Changes
1
Hide whitespace changes
Inline
Side-by-side
optimization_algo/approaches/cma_approach_square_size.py
View file @
094d8523
...
...
@@ -160,23 +160,36 @@ class cma_approach(object):
return
latencies
,
max_latency_idx
"""
Decide partition sizes and evaluate.
"""
def
eva_hybrid_sq
(
self
,
layer
):
# res is a list of length # of partitions. Step size is 3
res
=
[
self
.
res_step
]
*
self
.
k
latencies
=
[]
# TODO Change this to a binary search.
# max_res_unit = 1920*9*1 from sq_approach_faster
variable_max_res_unit
=
self
.
max_res_unit
while
sum
([
r
*
r
for
r
in
res
])
<
self
.
max_res_unit
:
# Generate initial solution
while
sum
([
r
*
r
for
r
in
res
])
<
variable_max_res_unit
:
latencies
,
max_idx
=
self
.
find_max_latency
(
layer
,
res
)
res
[
max_idx
]
+=
self
.
res_step
# for i in range(0, int(self.max_res_unit/self.res_step - self.k*self.res_step)):
# latencies, max_idx = self.find_max_latency(layer, res)
# res[max_idx] += self.res_step
while
pp
.
packingPenalty
(
res
,
self
)
!=
0
:
while
sum
([
r
*
r
for
r
in
res
])
<
variable_max_res_unit
:
latencies
,
max_idx
=
self
.
find_max_latency
(
layer
,
res
)
res
[
max_idx
]
+=
self
.
res_step
variable_max_res_unit
-=
100
# TODO we want to penalize based on how much we had to decrease
# variable_max_res_unit.
max_res_unit_decrease
=
self
.
max_res_unit
-
variable_max_res_unit
# If all layers couldn't be packed, packingPenalty returns 0.
packing_penalty
=
pp
.
packingPenalty
(
res
,
self
.
max_pack_size
)
if
packing_penalty
==
0
:
return
latencies
[
max_idx
],
latencies
,
res
,
layer
return
latencies
[
max_idx
]
+
packing_penalty
,
latencies
,
res
,
layer
def
evaluation_top_level
(
self
,
in_val
):
...
...
@@ -192,12 +205,9 @@ class cma_approach(object):
else
:
return
pid
,
penalty
*
4
# regroup_layers assigns layers to the partitions. Returns a list of
# partition lists which contain layers.
layer
=
self
.
regroup_layers
(
layer
)
# if self.is_hybrid:
# return pid, self.eva_hybrid_sq(layer)[0]
# else:
# score, _, res, _ = self.evaluate_full_relaxed(layer)
# return pid, score, res
return
pid
,
self
.
eva_hybrid_sq
(
layer
)[
0
]
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment