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
b2225436
Unverified
Commit
b2225436
authored
Jun 20, 2021
by
Bill Wu
Committed by
GitHub
Jun 21, 2021
Browse files
flops counter formatting fix (#3837)
parent
91ef554d
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
3 additions
and
2 deletions
+3
-2
nni/compression/pytorch/utils/counter.py
nni/compression/pytorch/utils/counter.py
+3
-2
No files found.
nni/compression/pytorch/utils/counter.py
View file @
b2225436
...
@@ -313,12 +313,13 @@ class ModelProfiler:
...
@@ -313,12 +313,13 @@ class ModelProfiler:
table
.
field_names
=
headers
table
.
field_names
=
headers
for
i
,
result
in
enumerate
(
self
.
results
):
for
i
,
result
in
enumerate
(
self
.
results
):
flops_count
=
int
(
result
[
'flops'
].
item
())
if
isinstance
(
result
[
'flops'
],
torch
.
Tensor
)
else
int
(
result
[
'flops'
])
row_values
=
[
row_values
=
[
i
,
i
,
result
[
'name'
],
result
[
'name'
],
result
[
'module_type'
],
result
[
'module_type'
],
str
(
result
[
'weight_shape'
]),
str
(
result
[
'weight_shape'
]),
result
[
'flops'
]
,
flops_count
,
result
[
'params'
],
result
[
'params'
],
]
]
name_counter
[
result
[
'name'
]]
+=
1
name_counter
[
result
[
'name'
]]
+=
1
...
@@ -408,4 +409,4 @@ def count_flops_params(model, x, custom_ops=None, verbose=True, mode='default'):
...
@@ -408,4 +409,4 @@ def count_flops_params(model, x, custom_ops=None, verbose=True, mode='default'):
print
(
f
'FLOPs total:
{
profiler
.
sum_flops
()
}
'
)
print
(
f
'FLOPs total:
{
profiler
.
sum_flops
()
}
'
)
print
(
f
'#Params total:
{
profiler
.
sum_params
()
}
'
)
print
(
f
'#Params total:
{
profiler
.
sum_params
()
}
'
)
return
profiler
.
sum_flops
(),
profiler
.
sum_params
(),
profiler
.
results
return
profiler
.
sum_flops
(),
profiler
.
sum_params
(),
profiler
.
results
\ No newline at end of file
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