Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
e1ceae41
Unverified
Commit
e1ceae41
authored
Jan 28, 2021
by
Yuge Zhang
Committed by
GitHub
Jan 28, 2021
Browse files
[Retiarii] Fix record conflicts (#3345)
parent
64efd60a
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
2 deletions
+11
-2
nni/retiarii/nn/pytorch/nn.py
nni/retiarii/nn/pytorch/nn.py
+10
-1
nni/retiarii/utils.py
nni/retiarii/utils.py
+1
-1
No files found.
nni/retiarii/nn/pytorch/nn.py
View file @
e1ceae41
...
@@ -4,7 +4,7 @@ from typing import Any, List
...
@@ -4,7 +4,7 @@ from typing import Any, List
import
torch
import
torch
import
torch.nn
as
nn
import
torch.nn
as
nn
from
...utils
import
add_record
,
blackbox_module
,
uid
,
version_larger_equal
from
...utils
import
add_record
,
blackbox_module
,
del_record
,
uid
,
version_larger_equal
_logger
=
logging
.
getLogger
(
__name__
)
_logger
=
logging
.
getLogger
(
__name__
)
...
@@ -93,6 +93,9 @@ class Placeholder(nn.Module):
...
@@ -93,6 +93,9 @@ class Placeholder(nn.Module):
def
forward
(
self
,
x
):
def
forward
(
self
,
x
):
return
x
return
x
def
__del__
(
self
):
del_record
(
id
(
self
))
class
ChosenInputs
(
nn
.
Module
):
class
ChosenInputs
(
nn
.
Module
):
"""
"""
...
@@ -133,12 +136,18 @@ class Sequential(nn.Sequential):
...
@@ -133,12 +136,18 @@ class Sequential(nn.Sequential):
add_record
(
id
(
self
),
{})
add_record
(
id
(
self
),
{})
super
(
Sequential
,
self
).
__init__
(
*
args
)
super
(
Sequential
,
self
).
__init__
(
*
args
)
def
__del__
(
self
):
del_record
(
id
(
self
))
class
ModuleList
(
nn
.
ModuleList
):
class
ModuleList
(
nn
.
ModuleList
):
def
__init__
(
self
,
*
args
):
def
__init__
(
self
,
*
args
):
add_record
(
id
(
self
),
{})
add_record
(
id
(
self
),
{})
super
(
ModuleList
,
self
).
__init__
(
*
args
)
super
(
ModuleList
,
self
).
__init__
(
*
args
)
def
__del__
(
self
):
del_record
(
id
(
self
))
Identity
=
blackbox_module
(
nn
.
Identity
)
Identity
=
blackbox_module
(
nn
.
Identity
)
Linear
=
blackbox_module
(
nn
.
Linear
)
Linear
=
blackbox_module
(
nn
.
Linear
)
...
...
nni/retiarii/utils.py
View file @
e1ceae41
...
@@ -37,7 +37,7 @@ def add_record(key, value):
...
@@ -37,7 +37,7 @@ def add_record(key, value):
"""
"""
global
_records
global
_records
if
_records
is
not
None
:
if
_records
is
not
None
:
assert
key
not
in
_records
,
'{} already in _records
'
.
format
(
key
)
assert
key
not
in
_records
,
f
'
{
key
}
already in _records
. Conflict:
{
_records
[
key
]
}
'
_records
[
key
]
=
value
_records
[
key
]
=
value
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a 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