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
9758f784
Commit
9758f784
authored
1 year ago
by
Oscar Gustafsson
Browse files
Options
Downloads
Patches
Plain Diff
Add support for removing empty resources from architecture
parent
03ecf153
No related branches found
No related tags found
No related merge requests found
Pipeline
#103293
failed
1 year ago
Stage: test
Changes
2
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
b_asic/architecture.py
+39
-3
39 additions, 3 deletions
b_asic/architecture.py
examples/fivepointwinograddft.py
+6
-1
6 additions, 1 deletion
examples/fivepointwinograddft.py
with
45 additions
and
4 deletions
b_asic/architecture.py
+
39
−
3
View file @
9758f784
...
...
@@ -764,19 +764,55 @@ of :class:`~b_asic.architecture.ProcessingElement`
d_out
[
i
][
v
]
+=
1
return
[
dict
(
d
)
for
d
in
d_in
],
[
dict
(
d
)
for
d
in
d_out
]
def
resource_from_name
(
self
,
name
:
str
):
def
resource_from_name
(
self
,
name
:
str
)
->
Resource
:
"""
Get :class:`Resource` based on name.
Parameters
----------
name : str
Name of the resource.
Returns
-------
:class:`Resource`
"""
re
=
{
p
.
entity_name
:
p
for
p
in
chain
(
self
.
memories
,
self
.
processing_elements
)}
return
re
[
name
]
def
remove_resource
(
self
,
resource
:
Union
[
str
,
Resource
],
)
->
None
:
"""
Remove an empty :class:`Resource` from the architecture.
Parameters
----------
resource : :class:`b_asic.architecture.Resource` or str
The resource or the resource name to remove.
"""
if
isinstance
(
resource
,
str
):
resource
=
self
.
resource_from_name
(
resource
)
if
resource
.
collection
:
raise
ValueError
(
"
Resource must be empty
"
)
if
resource
in
self
.
memories
:
self
.
memories
.
remove
(
resource
)
else
:
self
.
processing_elements
.
remove
(
resource
)
def
move_process
(
self
,
proc
:
Union
[
str
,
Process
],
re_from
:
Union
[
str
,
Resource
],
re_to
:
Union
[
str
,
Resource
],
assign
:
bool
=
False
,
):
)
->
None
:
"""
Move a :class:`b_asic.process.Process` from one
r
esource to another.
Move a :class:`b_asic.process.Process` from one
:class:`R
esource
`
to another.
Both the resource moved from and will become unassigned after a process has been
moved, unless *assign* is set to True.
...
...
This diff is collapsed.
Click to expand it.
examples/fivepointwinograddft.py
+
6
−
1
View file @
9758f784
...
...
@@ -196,7 +196,12 @@ memories[0].assign()
memories
[
1
].
assign
()
memories
[
4
].
assign
()
for
memory
in
memories
:
# %%
# Memory 4 is now empty, so remove it.
arch
.
remove_resource
(
'
memory4
'
)
for
memory
in
arch
.
memories
:
memory
.
show_content
(
title
=
f
"
Improved
{
memory
.
entity_name
}
"
)
arch
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