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
e817f13a
Commit
e817f13a
authored
2 years ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Improve repr for resources
parent
72bf5ff3
No related branches found
Branches containing commit
No related tags found
Tags containing commit
1 merge request
!202
Improve repr for resources
Pipeline
#89909
passed
2 years ago
Stage: test
Changes
4
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
b_asic/process.py
+19
-0
19 additions, 0 deletions
b_asic/process.py
b_asic/resources.py
+13
-0
13 additions, 0 deletions
b_asic/resources.py
b_asic/schedule.py
+18
-2
18 additions, 2 deletions
b_asic/schedule.py
examples/threepointwinograddft.py
+2
-0
2 additions, 0 deletions
examples/threepointwinograddft.py
with
52 additions
and
2 deletions
b_asic/process.py
+
19
−
0
View file @
e817f13a
...
...
@@ -58,6 +58,11 @@ class Process:
def
__str__
(
self
)
->
str
:
return
self
.
_name
def
__repr__
(
self
)
->
str
:
return
(
f
"
Process(
{
self
.
start_time
}
,
{
self
.
execution_time
}
,
{
self
.
name
}
)
"
)
# Static counter for default names
_name_cnt
=
0
...
...
@@ -142,6 +147,13 @@ class MemoryVariable(Process):
def
write_port
(
self
)
->
OutputPort
:
return
self
.
_write_port
def
__repr__
(
self
)
->
str
:
reads
=
{
k
:
v
for
k
,
v
in
zip
(
self
.
_read_ports
,
self
.
_life_times
)}
return
(
f
"
MemoryVariable(
{
self
.
start_time
}
,
{
self
.
write_port
}
,
"
f
"
{
reads
!r}
,
{
self
.
name
!r}
)
"
)
class
PlainMemoryVariable
(
Process
):
"""
...
...
@@ -189,3 +201,10 @@ class PlainMemoryVariable(Process):
@property
def
write_port
(
self
)
->
int
:
return
self
.
_write_port
def
__repr__
(
self
)
->
str
:
reads
=
{
k
:
v
for
k
,
v
in
zip
(
self
.
_read_ports
,
self
.
_life_times
)}
return
(
f
"
PlainMemoryVariable(
{
self
.
start_time
}
,
{
self
.
write_port
}
,
"
f
"
{
reads
!r}
,
{
self
.
name
!r}
)
"
)
This diff is collapsed.
Click to expand it.
b_asic/resources.py
+
13
−
0
View file @
e817f13a
import
io
import
re
from
typing
import
Dict
,
Iterable
,
List
,
Optional
,
Set
,
Tuple
,
TypeVar
,
Union
...
...
@@ -390,3 +391,15 @@ class ProcessCollection:
)
for
process_collection_set
in
process_collection_set_list
}
def
_repr_svg_
(
self
)
->
str
:
"""
Generate an SVG_ of the resource collection. This is automatically displayed in e.g.
Jupyter Qt console.
"""
fig
,
ax
=
plt
.
subplots
()
self
.
draw_lifetime_chart
(
ax
,
show_markers
=
False
)
f
=
io
.
StringIO
()
fig
.
savefig
(
f
,
format
=
"
svg
"
)
return
f
.
getvalue
()
This diff is collapsed.
Click to expand it.
b_asic/schedule.py
+
18
−
2
View file @
e817f13a
...
...
@@ -32,6 +32,7 @@ from b_asic.graph_component import GraphID
from
b_asic.operation
import
Operation
from
b_asic.port
import
InputPort
,
OutputPort
from
b_asic.process
import
MemoryVariable
,
Process
from
b_asic.resources
import
ProcessCollection
from
b_asic.signal_flow_graph
import
SFG
from
b_asic.special_operations
import
Delay
,
Output
...
...
@@ -583,8 +584,8 @@ class Schedule:
]
+
cast
(
int
,
source_port
.
latency_offset
)
self
.
_remove_delays
()
def
_get_memory_variables_list
(
self
)
->
List
[
'
Process
'
]:
ret
:
List
[
'
Process
'
]
=
[]
def
_get_memory_variables_list
(
self
)
->
List
[
'
MemoryVariable
'
]:
ret
:
List
[
'
MemoryVariable
'
]
=
[]
for
graph_id
,
start_time
in
self
.
_start_times
.
items
():
slacks
=
self
.
_forward_slacks
(
graph_id
)
for
outport
,
signals
in
slacks
.
items
():
...
...
@@ -597,10 +598,25 @@ class Schedule:
start_time
+
cast
(
int
,
outport
.
latency_offset
),
outport
,
reads
,
outport
.
operation
.
graph_id
,
)
)
return
ret
def
get_memory_variables
(
self
)
->
ProcessCollection
:
"""
Return a :class:`~b_asic.resources.ProcessCollection` containing all
memory variables.
Returns
-------
ProcessCollection
"""
return
ProcessCollection
(
set
(
self
.
_get_memory_variables_list
()),
self
.
schedule_time
)
def
_get_y_position
(
self
,
graph_id
,
operation_height
=
1.0
,
operation_gap
=
None
)
->
float
:
...
...
This diff is collapsed.
Click to expand it.
examples/threepointwinograddft.py
+
2
−
0
View file @
e817f13a
...
...
@@ -54,3 +54,5 @@ sfg.set_execution_time_of_type(Subtraction.type_name(), 1)
# Generate schedule
schedule
=
Schedule
(
sfg
,
cyclic
=
True
)
schedule
.
plot
()
pc
=
schedule
.
get_memory_variables
()
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