Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
OpenDAS
nni
Commits
08fe2924
Unverified
Commit
08fe2924
authored
Jul 27, 2021
by
Yuge Zhang
Committed by
GitHub
Jul 27, 2021
Browse files
Merge pull request #3938 from microsoft/nn-meter
[DO NOT SQUASH] Support nn-Meter in Retiarii framework
parents
3bce6926
5e04d56c
Changes
21
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
27 additions
and
0 deletions
+27
-0
test/ut/retiarii/test_highlevel_apis.py
test/ut/retiarii/test_highlevel_apis.py
+27
-0
No files found.
test/ut/retiarii/test_highlevel_apis.py
View file @
08fe2924
...
@@ -111,6 +111,33 @@ class GraphIR(unittest.TestCase):
...
@@ -111,6 +111,33 @@ class GraphIR(unittest.TestCase):
self
.
assertEqual
(
self
.
_get_converted_pytorch_model
(
model_new
)(
torch
.
randn
(
1
,
3
,
3
,
3
)).
size
(),
self
.
assertEqual
(
self
.
_get_converted_pytorch_model
(
model_new
)(
torch
.
randn
(
1
,
3
,
3
,
3
)).
size
(),
torch
.
Size
([
1
,
i
,
3
,
3
]))
torch
.
Size
([
1
,
i
,
3
,
3
]))
def
test_nested_layer_choice
(
self
):
@
self
.
get_serializer
()
class
Net
(
nn
.
Module
):
def
__init__
(
self
):
super
().
__init__
()
self
.
module
=
nn
.
LayerChoice
([
nn
.
LayerChoice
([
nn
.
Conv2d
(
3
,
3
,
kernel_size
=
1
),
nn
.
Conv2d
(
3
,
4
,
kernel_size
=
1
),
nn
.
Conv2d
(
3
,
5
,
kernel_size
=
1
)]),
nn
.
Conv2d
(
3
,
1
,
kernel_size
=
1
)
])
def
forward
(
self
,
x
):
return
self
.
module
(
x
)
model
,
mutators
=
self
.
_get_model_with_mutators
(
Net
())
self
.
assertEqual
(
len
(
mutators
),
2
)
mutators
[
0
].
bind_sampler
(
EnumerateSampler
())
mutators
[
1
].
bind_sampler
(
EnumerateSampler
())
input
=
torch
.
randn
(
1
,
3
,
5
,
5
)
self
.
assertEqual
(
self
.
_get_converted_pytorch_model
(
mutators
[
1
].
apply
(
mutators
[
0
].
apply
(
model
)))(
input
).
size
(),
torch
.
Size
([
1
,
3
,
5
,
5
]))
self
.
assertEqual
(
self
.
_get_converted_pytorch_model
(
mutators
[
1
].
apply
(
mutators
[
0
].
apply
(
model
)))(
input
).
size
(),
torch
.
Size
([
1
,
1
,
5
,
5
]))
self
.
assertEqual
(
self
.
_get_converted_pytorch_model
(
mutators
[
1
].
apply
(
mutators
[
0
].
apply
(
model
)))(
input
).
size
(),
torch
.
Size
([
1
,
5
,
5
,
5
]))
def
test_input_choice
(
self
):
def
test_input_choice
(
self
):
@
self
.
get_serializer
()
@
self
.
get_serializer
()
class
Net
(
nn
.
Module
):
class
Net
(
nn
.
Module
):
...
...
Prev
1
2
Next
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