Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
I
ICV-mmengine_basecode
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Service Desk
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Florian Schiffel
ICV-mmengine_basecode
Commits
83d76abc
Unverified
Commit
83d76abc
authored
1 year ago
by
CescMessi
Committed by
GitHub
1 year ago
Browse files
Options
Downloads
Patches
Plain Diff
[Fix] Fix the incorrect device of inputs in get_model_complexity_info (#1130)
parent
2085046d
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
mmengine/analysis/print_helper.py
+3
-2
3 additions, 2 deletions
mmengine/analysis/print_helper.py
with
3 additions
and
2 deletions
mmengine/analysis/print_helper.py
+
3
−
2
View file @
83d76abc
...
...
@@ -725,14 +725,15 @@ def get_model_complexity_info(
raise
ValueError
(
'"
input_shape
"
and
"
inputs
"
cannot be both set.
'
)
if
inputs
is
None
:
device
=
next
(
model
.
parameters
()).
device
if
is_tuple_of
(
input_shape
,
int
):
# tuple of int, construct one tensor
inputs
=
(
torch
.
randn
(
1
,
*
input_shape
),
)
inputs
=
(
torch
.
randn
(
1
,
*
input_shape
)
.
to
(
device
)
,
)
elif
is_tuple_of
(
input_shape
,
tuple
)
and
all
([
is_tuple_of
(
one_input_shape
,
int
)
for
one_input_shape
in
input_shape
# type: ignore
]):
# tuple of tuple of int, construct multiple tensors
inputs
=
tuple
([
torch
.
randn
(
1
,
*
one_input_shape
)
torch
.
randn
(
1
,
*
one_input_shape
)
.
to
(
device
)
for
one_input_shape
in
input_shape
# type: ignore
])
else
:
...
...
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