Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
B-ASIC - Better ASIC Toolbox
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Locked files
Build
Pipelines
Jobs
Pipeline schedules
Test cases
Artifacts
Deploy
Releases
Package registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Computer Engineering
B-ASIC - Better ASIC Toolbox
Commits
81491e13
Commit
81491e13
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Change return type for coordinates to tuples and split port methods
parent
e06e5026
No related branches found
No related tags found
1 merge request
!172
Change return type for coordinates to tuples and split port methods
Pipeline
#89091
passed
2 years ago
Stage: test
Changes
4
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
b_asic/operation.py
+80
-35
80 additions, 35 deletions
b_asic/operation.py
b_asic/schedule.py
+3
-6
3 additions, 6 deletions
b_asic/schedule.py
b_asic/special_operations.py
+34
-30
34 additions, 30 deletions
b_asic/special_operations.py
test/test_operation.py
+25
-18
25 additions, 18 deletions
test/test_operation.py
with
142 additions
and
89 deletions
b_asic/operation.py
+
80
−
35
View file @
81491e13
...
...
@@ -407,7 +407,7 @@ class Operation(GraphComponent, SignalSourceProvider):
@abstractmethod
def
get_plot_coordinates
(
self
,
)
->
Tuple
[
List
[
List
[
float
]],
List
[
List
[
float
]]]:
)
->
Tuple
[
Tuple
[
Tuple
[
float
]],
Tuple
[
Tuple
[
float
]]]:
"""
Return a tuple containing coordinates for the two polygons outlining
the latency and execution time of the operation.
...
...
@@ -418,11 +418,49 @@ class Operation(GraphComponent, SignalSourceProvider):
@abstractmethod
def
get_io_coordinates
(
self
,
)
->
Tuple
[
List
[
List
[
float
]],
List
[
List
[
float
]]]:
)
->
Tuple
[
Tuple
[
Tuple
[
float
]],
Tuple
[
Tuple
[
float
]]]:
"""
Return a tuple containing coordinates for inputs and outputs, respectively.
These maps to the polygons and are corresponding to a start time of 0
and height 1.
See also
========
get_input_coordinates
get_output_coordinates
"""
raise
NotImplementedError
@abstractmethod
def
get_input_coordinates
(
self
,
)
->
Tuple
[
Tuple
[
float
]]:
"""
Return coordinates for inputs.
These maps to the polygons and are corresponding to a start time of 0
and height 1.
See also
========
get_io_coordinates
get_output_coordinates
"""
raise
NotImplementedError
@abstractmethod
def
get_output_coordinates
(
self
,
)
->
Tuple
[
Tuple
[
float
]]:
"""
Return coordinates for outputs.
These maps to the polygons and are corresponding to a start time of 0
and height 1.
See also
========
get_input_coordinates
get_io_coordinates
"""
raise
NotImplementedError
...
...
@@ -1044,25 +1082,25 @@ class AbstractOperation(Operation, AbstractGraphComponent):
def
get_plot_coordinates
(
self
,
)
->
Tuple
[
List
[
List
[
float
]],
List
[
List
[
float
]]]:
)
->
Tuple
[
Tuple
[
Tuple
[
float
]],
Tuple
[
Tuple
[
float
]]]:
# Doc-string inherited
return
(
self
.
_get_plot_coordinates_for_latency
(),
self
.
_get_plot_coordinates_for_execution_time
(),
)
def
_get_plot_coordinates_for_execution_time
(
self
)
->
List
[
List
[
float
]]:
def
_get_plot_coordinates_for_execution_time
(
self
)
->
Tuple
[
Tuple
[
float
]]:
# Always a rectangle, but easier if coordinates are returned
execution_time
=
self
.
_execution_time
# Copy for type checking
if
execution_time
is
None
:
return
[]
return
[
[
0
,
0
]
,
[
0
,
1
]
,
[
execution_time
,
1
]
,
[
execution_time
,
0
]
,
[
0
,
0
]
,
]
return
tuple
()
return
(
(
0
,
0
)
,
(
0
,
1
)
,
(
execution_time
,
1
)
,
(
execution_time
,
0
)
,
(
0
,
0
)
,
)
def
_check_all_latencies_set
(
self
):
if
any
(
val
is
None
for
val
in
self
.
latency_offsets
.
values
()):
...
...
@@ -1070,47 +1108,54 @@ class AbstractOperation(Operation, AbstractGraphComponent):
f
"
All latencies must be set:
{
self
.
latency_offsets
}
"
)
def
_get_plot_coordinates_for_latency
(
self
)
->
List
[
List
[
float
]]:
def
_get_plot_coordinates_for_latency
(
self
)
->
Tuple
[
Tuple
[
float
]]:
self
.
_check_all_latencies_set
()
# Points for latency polygon
latency
=
[]
# Remember starting point
start_point
=
[
self
.
inputs
[
0
].
latency_offset
,
0.0
]
start_point
=
(
self
.
inputs
[
0
].
latency_offset
,
0.0
)
num_in
=
self
.
input_count
latency
.
append
(
start_point
)
for
k
in
range
(
1
,
num_in
):
latency
.
append
(
[
self
.
inputs
[
k
-
1
].
latency_offset
,
k
/
num_in
]
)
latency
.
append
(
[
self
.
inputs
[
k
].
latency_offset
,
k
/
num_in
]
)
latency
.
append
(
[
self
.
inputs
[
num_in
-
1
].
latency_offset
,
1
]
)
latency
.
append
(
(
self
.
inputs
[
k
-
1
].
latency_offset
,
k
/
num_in
)
)
latency
.
append
(
(
self
.
inputs
[
k
].
latency_offset
,
k
/
num_in
)
)
latency
.
append
(
(
self
.
inputs
[
num_in
-
1
].
latency_offset
,
1
)
)
num_out
=
self
.
output_count
latency
.
append
(
[
self
.
outputs
[
num_out
-
1
].
latency_offset
,
1
]
)
latency
.
append
(
(
self
.
outputs
[
num_out
-
1
].
latency_offset
,
1
)
)
for
k
in
reversed
(
range
(
1
,
num_out
)):
latency
.
append
(
[
self
.
outputs
[
k
].
latency_offset
,
k
/
num_out
]
)
latency
.
append
(
[
self
.
outputs
[
k
-
1
].
latency_offset
,
k
/
num_out
]
)
latency
.
append
(
[
self
.
outputs
[
0
].
latency_offset
,
0.0
]
)
latency
.
append
(
(
self
.
outputs
[
k
].
latency_offset
,
k
/
num_out
)
)
latency
.
append
(
(
self
.
outputs
[
k
-
1
].
latency_offset
,
k
/
num_out
)
)
latency
.
append
(
(
self
.
outputs
[
0
].
latency_offset
,
0.0
)
)
# Close the polygon
latency
.
append
(
start_point
)
return
latency
return
tuple
(
latency
)
def
get_io_coordinates
(
self
,
)
->
Tuple
[
List
[
List
[
float
]],
List
[
List
[
float
]]]:
# Doc-string inherited
def
get_input_coordinates
(
self
)
->
Tuple
[
Tuple
[
float
]]:
# doc-string inherited
self
.
_check_all_latencies_set
()
input_coordinates
=
[
[
return
tuple
(
(
self
.
inputs
[
k
].
latency_offset
,
(
1
+
2
*
k
)
/
(
2
*
len
(
self
.
inputs
)),
]
)
for
k
in
range
(
len
(
self
.
inputs
))
]
output_coordinates
=
[
[
)
def
get_output_coordinates
(
self
)
->
Tuple
[
Tuple
[
float
]]:
# doc-string inherited
self
.
_check_all_latencies_set
()
return
tuple
(
(
self
.
outputs
[
k
].
latency_offset
,
(
1
+
2
*
k
)
/
(
2
*
len
(
self
.
outputs
)),
]
)
for
k
in
range
(
len
(
self
.
outputs
))
]
return
input_coordinates
,
output_coordinates
)
def
get_io_coordinates
(
self
,
)
->
Tuple
[
Tuple
[
Tuple
[
float
]],
Tuple
[
Tuple
[
float
]]]:
# Doc-string inherited
return
self
.
get_input_coordinates
(),
self
.
get_output_coordinates
()
This diff is collapsed.
Click to expand it.
b_asic/schedule.py
+
3
−
6
View file @
81491e13
...
...
@@ -745,7 +745,7 @@ class Schedule:
for
graph_id
,
op_start_time
in
self
.
_start_times
.
items
():
op
=
self
.
_sfg
.
find_by_id
(
graph_id
)
_
,
out_coordinates
=
op
.
get_
i
o_coordinates
()
out_coordinates
=
op
.
get_o
utput
_coordinates
()
source_y_pos
=
self
.
_get_y_position
(
graph_id
,
operation_gap
=
operation_gap
)
...
...
@@ -759,11 +759,8 @@ class Schedule:
destination_y_pos
=
self
.
_get_y_position
(
destination_op
.
graph_id
,
operation_gap
=
operation_gap
)
(
destination_in_coordinates
,
_
,
)
=
(
output_signal
.
destination
.
operation
.
get_io_coordinates
()
destination_in_coordinates
=
(
output_signal
.
destination
.
operation
.
get_input_coordinates
()
)
_draw_offset_arrow
(
out_coordinates
[
output_port
.
index
],
...
...
This diff is collapsed.
Click to expand it.
b_asic/special_operations.py
+
34
−
30
View file @
81491e13
...
...
@@ -57,32 +57,34 @@ class Input(AbstractOperation):
def
get_plot_coordinates
(
self
,
)
->
Tuple
[
List
[
List
[
float
]],
List
[
List
[
float
]]]:
)
->
Tuple
[
Tuple
[
Tuple
[
float
]],
Tuple
[
Tuple
[
float
]]]:
# Doc-string inherited
return
(
[
[
-
0.5
,
0
]
,
[
-
0.5
,
1
]
,
[
-
0.25
,
1
]
,
[
0
,
0.5
]
,
[
-
0.25
,
0
]
,
[
-
0.5
,
0
]
,
]
,
[
[
-
0.5
,
0
]
,
[
-
0.5
,
1
]
,
[
-
0.25
,
1
]
,
[
0
,
0.5
]
,
[
-
0.25
,
0
]
,
[
-
0.5
,
0
]
,
]
,
(
(
-
0.5
,
0
)
,
(
-
0.5
,
1
)
,
(
-
0.25
,
1
)
,
(
0
,
0.5
)
,
(
-
0.25
,
0
)
,
(
-
0.5
,
0
)
,
)
,
(
(
-
0.5
,
0
)
,
(
-
0.5
,
1
)
,
(
-
0.25
,
1
)
,
(
0
,
0.5
)
,
(
-
0.25
,
0
)
,
(
-
0.5
,
0
)
,
)
,
)
def
get_io_coordinates
(
self
,
)
->
Tuple
[
List
[
List
[
float
]],
List
[
List
[
float
]]]:
# Doc-string inherited
return
([],
[[
0
,
0.5
]])
def
get_input_coordinates
(
self
)
->
Tuple
[
Tuple
[
float
]]:
# doc-string inherited
return
tuple
()
def
get_output_coordinates
(
self
)
->
Tuple
[
Tuple
[
float
]]:
# doc-string inherited
return
((
0
,
0.5
),)
class
Output
(
AbstractOperation
):
...
...
@@ -119,18 +121,20 @@ class Output(AbstractOperation):
def
get_plot_coordinates
(
self
,
)
->
Tuple
[
List
[
List
[
float
]],
List
[
List
[
float
]]]:
)
->
Tuple
[
Tuple
[
Tuple
[
float
]],
Tuple
[
Tuple
[
float
]]]:
# Doc-string inherited
return
(
[[
0
,
0
]
,
[
0
,
1
]
,
[
0.25
,
1
]
,
[
0.5
,
0.5
]
,
[
0.25
,
0
]
,
[
0
,
0
]]
,
[[
0
,
0
]
,
[
0
,
1
]
,
[
0.25
,
1
]
,
[
0.5
,
0.5
]
,
[
0.25
,
0
]
,
[
0
,
0
]]
,
((
0
,
0
)
,
(
0
,
1
)
,
(
0.25
,
1
)
,
(
0.5
,
0.5
)
,
(
0.25
,
0
)
,
(
0
,
0
))
,
((
0
,
0
)
,
(
0
,
1
)
,
(
0.25
,
1
)
,
(
0.5
,
0.5
)
,
(
0.25
,
0
)
,
(
0
,
0
))
,
)
def
get_io_coordinates
(
self
,
)
->
Tuple
[
List
[
List
[
float
]],
List
[
List
[
float
]]]:
# Doc-string inherited
return
([[
0
,
0.5
]],
[])
def
get_input_coordinates
(
self
)
->
Tuple
[
Tuple
[
float
]]:
# doc-string inherited
return
((
0
,
0.5
),)
def
get_output_coordinates
(
self
)
->
Tuple
[
Tuple
[
float
]]:
# doc-string inherited
return
tuple
()
class
Delay
(
AbstractOperation
):
...
...
This diff is collapsed.
Click to expand it.
test/test_operation.py
+
25
−
18
View file @
81491e13
...
...
@@ -270,8 +270,8 @@ class TestPlotCoordinates:
cmult
.
set_latency
(
3
)
lat
,
exe
=
cmult
.
get_plot_coordinates
()
assert
lat
==
[[
0
,
0
]
,
[
0
,
1
]
,
[
3
,
1
]
,
[
3
,
0
]
,
[
0
,
0
]]
assert
exe
==
[[
0
,
0
]
,
[
0
,
1
]
,
[
1
,
1
]
,
[
1
,
0
]
,
[
0
,
0
]]
assert
lat
==
((
0
,
0
)
,
(
0
,
1
)
,
(
3
,
1
)
,
(
3
,
0
)
,
(
0
,
0
))
assert
exe
==
((
0
,
0
)
,
(
0
,
1
)
,
(
1
,
1
)
,
(
1
,
0
)
,
(
0
,
0
))
def
test_complicated_case
(
self
):
bfly
=
Butterfly
(
...
...
@@ -280,18 +280,18 @@ class TestPlotCoordinates:
bfly
.
execution_time
=
7
lat
,
exe
=
bfly
.
get_plot_coordinates
()
assert
lat
==
[
[
2
,
0
]
,
[
2
,
0.5
]
,
[
3
,
0.5
]
,
[
3
,
1
]
,
[
10
,
1
]
,
[
10
,
0.5
]
,
[
5
,
0.5
]
,
[
5
,
0
]
,
[
2
,
0
]
,
]
assert
exe
==
[[
0
,
0
]
,
[
0
,
1
]
,
[
7
,
1
]
,
[
7
,
0
]
,
[
0
,
0
]]
assert
lat
==
(
(
2
,
0
)
,
(
2
,
0.5
)
,
(
3
,
0.5
)
,
(
3
,
1
)
,
(
10
,
1
)
,
(
10
,
0.5
)
,
(
5
,
0.5
)
,
(
5
,
0
)
,
(
2
,
0
)
,
)
assert
exe
==
((
0
,
0
)
,
(
0
,
1
)
,
(
7
,
1
)
,
(
7
,
0
)
,
(
0
,
0
))
class
TestIOCoordinates
:
...
...
@@ -301,8 +301,8 @@ class TestIOCoordinates:
cmult
.
set_latency
(
3
)
i_c
,
o_c
=
cmult
.
get_io_coordinates
()
assert
i_c
==
[[
0
,
0.5
]]
assert
o_c
==
[[
3
,
0.5
]]
assert
i_c
==
((
0
,
0.5
),)
assert
o_c
==
((
3
,
0.5
),)
def
test_complicated_case
(
self
):
bfly
=
Butterfly
(
...
...
@@ -311,8 +311,15 @@ class TestIOCoordinates:
bfly
.
execution_time
=
7
i_c
,
o_c
=
bfly
.
get_io_coordinates
()
assert
i_c
==
[[
2
,
0.25
],
[
3
,
0.75
]]
assert
o_c
==
[[
5
,
0.25
],
[
10
,
0.75
]]
assert
i_c
==
((
2
,
0.25
),
(
3
,
0.75
))
assert
o_c
==
((
5
,
0.25
),
(
10
,
0.75
))
def
test_io_coordinates_error
(
self
):
bfly
=
Butterfly
()
bfly
.
set_latency_offsets
({
"
in0
"
:
3
,
"
out1
"
:
5
})
with
pytest
.
raises
(
ValueError
,
match
=
"
All latencies must be set:
"
):
bfly
.
get_io_coordinates
()
class
TestSplit
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
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!
Save comment
Cancel
Please
register
or
sign in
to comment