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
gaoqiong
MIGraphX
Commits
c45afff0
Commit
c45afff0
authored
Apr 10, 2023
by
Paul
Browse files
Add some memory output
parent
f6e22d56
Changes
1
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
28 additions
and
0 deletions
+28
-0
src/pass_manager.cpp
src/pass_manager.cpp
+28
-0
No files found.
src/pass_manager.cpp
View file @
c45afff0
...
@@ -65,6 +65,32 @@ void run_pass(program& prog, const pass& p, tracer trace)
...
@@ -65,6 +65,32 @@ void run_pass(program& prog, const pass& p, tracer trace)
trace
(
prog
);
trace
(
prog
);
}
}
std
::
size_t
get_size
(
const
program
&
p
)
{
std
::
size_t
n
=
0
;
for
(
auto
*
mod
:
p
.
get_modules
())
{
for
(
const
auto
&
ins
:*
mod
)
{
if
(
ins
.
name
()
!=
"@literal"
)
continue
;
n
+=
ins
.
get_literal
().
get_shape
().
bytes
();
}
}
return
n
;
}
std
::
string
pretty_size
(
std
::
size_t
n
)
{
const
std
::
vector
<
std
::
string
>
keys
=
{
""
,
"K"
,
"M"
,
"G"
,
"T"
};
double
d
=
n
;
std
::
size_t
i
=
0
;
while
(
d
>
1024
and
i
<
keys
.
size
())
{
d
/=
1024
;
i
++
;
}
return
std
::
to_string
(
d
)
+
keys
[
std
::
max
<
std
::
ptrdiff_t
>
(
0
,
i
-
1
)];
}
struct
module_pm
:
module_pass_manager
struct
module_pm
:
module_pass_manager
{
{
module
*
mod
=
nullptr
;
module
*
mod
=
nullptr
;
...
@@ -139,6 +165,7 @@ void run_passes(program& prog, const std::vector<pass>& passes, tracer trace)
...
@@ -139,6 +165,7 @@ void run_passes(program& prog, const std::vector<pass>& passes, tracer trace)
std
::
unordered_set
<
module_ref
>
visited
;
std
::
unordered_set
<
module_ref
>
visited
;
for
(
const
auto
&
p
:
passes
)
for
(
const
auto
&
p
:
passes
)
{
{
std
::
cout
<<
p
.
name
()
<<
": "
<<
pretty_size
(
get_size
(
prog
))
<<
std
::
endl
;
auto
mods
=
prog
.
get_modules
();
auto
mods
=
prog
.
get_modules
();
auto
tree
=
prog
.
get_module_tree
();
auto
tree
=
prog
.
get_module_tree
();
visited
.
clear
();
visited
.
clear
();
...
@@ -163,6 +190,7 @@ void run_passes(program& prog, const std::vector<pass>& passes, tracer trace)
...
@@ -163,6 +190,7 @@ void run_passes(program& prog, const std::vector<pass>& passes, tracer trace)
mpm
.
run_pass
(
p
);
mpm
.
run_pass
(
p
);
}
}
run_pass
(
prog
,
p
,
trace
);
run_pass
(
prog
,
p
,
trace
);
std
::
cout
<<
p
.
name
()
<<
": "
<<
pretty_size
(
get_size
(
prog
))
<<
std
::
endl
;
}
}
}
}
...
...
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