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
583888ea
Commit
583888ea
authored
Feb 18, 2022
by
Shucai Xiao
Browse files
refine print out program
parent
7fce121e
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
24 additions
and
22 deletions
+24
-22
src/include/migraphx/program.hpp
src/include/migraphx/program.hpp
+2
-1
src/module.cpp
src/module.cpp
+2
-1
src/program.cpp
src/program.cpp
+11
-11
test/print_graph_test.cpp
test/print_graph_test.cpp
+6
-6
test/program_test.cpp
test/program_test.cpp
+3
-3
No files found.
src/include/migraphx/program.hpp
View file @
583888ea
...
...
@@ -76,7 +76,8 @@ struct program
void
from_value
(
const
value
&
v
);
void
debug_print
()
const
;
void
debug_print
(
instruction_ref
ins
)
const
;
void
debug_print
(
instruction_ref
ins
,
const
std
::
unordered_map
<
instruction_ref
,
std
::
string
>&
ins_names
)
const
;
void
print
(
std
::
unordered_map
<
instruction_ref
,
std
::
string
>&
names
,
const
std
::
function
<
void
(
instruction_ref
,
std
::
unordered_map
<
instruction_ref
,
std
::
string
>
)
>&
...
...
src/module.cpp
View file @
583888ea
...
...
@@ -627,8 +627,9 @@ std::unordered_map<instruction_ref, std::string> module::print(
var_name
=
this
->
name
();
var_name
.
append
((
this
->
name
().
empty
()
?
"@"
:
":@"
));
var_name
.
append
(
std
::
to_string
(
count
));
count
++
;
}
// count every instruction so index matches loc in the printout program
count
++
;
names
.
emplace
(
ins
,
var_name
);
print_func
(
ins
,
names
);
...
...
src/program.cpp
View file @
583888ea
...
...
@@ -353,13 +353,17 @@ std::vector<argument> program::eval(parameter_map params) const
if
(
trace_level
>
0
)
{
std
::
unordered_map
<
instruction_ref
,
std
::
string
>
ins_names
;
// get instruction names
this
->
print
(
ins_names
,
[](
auto
,
auto
)
{});
return
generic_eval
(
*
this
,
ctx
,
std
::
move
(
params
),
with_check_context
([
&
](
auto
&
ins
,
auto
f
,
auto
&&
check_context
)
{
ctx
.
finish
();
std
::
cout
<<
"Run instruction: "
;
this
->
debug_print
(
ins
);
this
->
debug_print
(
ins
,
ins_names
);
std
::
cout
<<
std
::
endl
;
timer
t
{};
auto
result
=
check_context
(
f
);
double
t1
=
t
.
record
<
milliseconds
>
();
...
...
@@ -703,9 +707,9 @@ void program::perf_report(std::ostream& os,
}
void
program
::
debug_print
()
const
{
std
::
cout
<<
*
this
<<
std
::
endl
;
}
void
program
::
debug_print
(
instruction_ref
ins
)
const
void
program
::
debug_print
(
instruction_ref
ins
,
const
std
::
unordered_map
<
instruction_ref
,
std
::
string
>&
ins_names
)
const
{
std
::
unordered_map
<
instruction_ref
,
std
::
string
>
names
;
if
(
std
::
any_of
(
this
->
impl
->
modules
.
begin
(),
this
->
impl
->
modules
.
end
(),
[
&
](
const
auto
&
pp
)
{
return
is_end
(
pp
.
second
.
end
(),
ins
);
}))
...
...
@@ -721,14 +725,10 @@ void program::debug_print(instruction_ref ins) const
return
;
}
std
::
stringstream
ss
;
this
->
print
(
names
,
[
&
](
auto
x
,
auto
ins_names
)
{
if
(
x
==
ins
)
{
instruction
::
print
(
std
::
cout
,
x
,
ins_names
);
std
::
cout
<<
std
::
endl
;
}
});
if
(
contains
(
ins_names
,
ins
))
{
instruction
::
print
(
std
::
cout
,
ins
,
ins_names
);
}
}
void
program
::
print
(
...
...
test/print_graph_test.cpp
View file @
583888ea
...
...
@@ -34,12 +34,12 @@ TEST_CASE(basic_graph_test)
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
main:@0
\"
[label=
\"
@literal
\"
]"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
y
\"
[label=
\"
@param:y
\"
]"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
x
\"
[label=
\"
@param:x
\"
]"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
main:@
1
\"
[label=
\"
sum
\"
]"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
main:@
2
\"
[label=
\"
sum
\"
]"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
x
\"
->
\"
main:@
1
\"
"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
y
\"
->
\"
main:@
1
\"
"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
main:@
1
\"
->
\"
main:@
2
\"
"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
main:@0
\"
->
\"
main:@
2
\"
"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
main:@
3
\"
[label=
\"
sum
\"
]"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
main:@
4
\"
[label=
\"
sum
\"
]"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
x
\"
->
\"
main:@
3
\"
"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
y
\"
->
\"
main:@
3
\"
"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
main:@
3
\"
->
\"
main:@
4
\"
"
));
EXPECT
(
migraphx
::
contains
(
test
,
"
\"
main:@0
\"
->
\"
main:@
4
\"
"
));
EXPECT
(
migraphx
::
contains
(
test
,
"[label=
\"
int64_type, {1}, {0}
\"
]"
));
}
...
...
test/program_test.cpp
View file @
583888ea
...
...
@@ -66,17 +66,17 @@ TEST_CASE(program_print)
auto
in1
=
mm
->
end
();
// print end instruction
p
.
debug_print
(
in1
);
p
.
debug_print
(
in1
,
{}
);
// print instruction not in the program
auto
p2
=
p
;
auto
*
mm2
=
p2
.
get_main_module
();
auto
in2
=
mm2
->
begin
();
p
.
debug_print
(
in2
);
p
.
debug_print
(
in2
,
{}
);
// print last instruction
auto
in3
=
std
::
prev
(
in1
);
p
.
debug_print
(
in3
);
p
.
debug_print
(
in3
,
{}
);
}
TEST_CASE
(
program_annotate
)
...
...
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