Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
a065486a
Unverified
Commit
a065486a
authored
Apr 04, 2019
by
mvermeulen
Committed by
GitHub
Apr 04, 2019
Browse files
Merge pull request #225 from ROCmSoftwarePlatform/dce-duplicate-args
Fix #222: Assertion in dead code elimination
parents
900bad8b
eb05b693
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
54 additions
and
1 deletion
+54
-1
src/dead_code_elimination.cpp
src/dead_code_elimination.cpp
+3
-1
test/dead_code_elimination_test.cpp
test/dead_code_elimination_test.cpp
+51
-0
No files found.
src/dead_code_elimination.cpp
View file @
a065486a
...
...
@@ -4,6 +4,7 @@
#include <migraphx/iterator_for.hpp>
#include <migraphx/functional.hpp>
#include <migraphx/ranges.hpp>
#include <unordered_set>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
...
...
@@ -50,7 +51,8 @@ void dead_code_elimination::apply(program& p) const
assert
(
p
.
has_instruction
(
leaf
));
if
(
leaf
->
outputs
().
empty
())
{
auto
args
=
leaf
->
inputs
();
std
::
unordered_set
<
instruction_ref
>
args
(
leaf
->
inputs
().
begin
(),
leaf
->
inputs
().
end
());
leaf
->
clear_arguments
();
assert
(
bidistance
(
p
,
last
,
leaf
)
<
0
);
assert
(
leaf
!=
ins
);
...
...
test/dead_code_elimination_test.cpp
View file @
a065486a
...
...
@@ -129,4 +129,55 @@ TEST_CASE(undefined_test)
EXPECT
(
result
!=
migraphx
::
literal
{
4
});
}
TEST_CASE
(
duplicate_args1
)
{
migraphx
::
program
p
;
auto
l0
=
p
.
add_literal
(
0
);
auto
l3
=
p
.
add_literal
(
3
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l3
,
l3
);
p
.
add_instruction
(
migraphx
::
op
::
identity
{},
l0
);
auto
count
=
std
::
distance
(
p
.
begin
(),
p
.
end
());
p
.
compile
(
dce_target
{});
EXPECT
(
std
::
distance
(
p
.
begin
(),
p
.
end
())
!=
count
);
EXPECT
(
std
::
distance
(
p
.
begin
(),
p
.
end
())
==
2
);
auto
result
=
p
.
eval
({});
EXPECT
(
result
==
migraphx
::
literal
{
0
});
}
TEST_CASE
(
duplicate_args2
)
{
migraphx
::
program
p
;
auto
l0
=
p
.
add_literal
(
0
);
auto
l3
=
p
.
add_literal
(
3
);
auto
sum1
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l0
,
l3
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
sum1
,
l3
);
p
.
add_instruction
(
migraphx
::
op
::
identity
{},
l0
);
auto
count
=
std
::
distance
(
p
.
begin
(),
p
.
end
());
p
.
compile
(
dce_target
{});
EXPECT
(
std
::
distance
(
p
.
begin
(),
p
.
end
())
!=
count
);
EXPECT
(
std
::
distance
(
p
.
begin
(),
p
.
end
())
==
2
);
auto
result
=
p
.
eval
({});
EXPECT
(
result
==
migraphx
::
literal
{
0
});
}
TEST_CASE
(
duplicate_args3
)
{
migraphx
::
program
p
;
auto
l0
=
p
.
add_literal
(
0
);
auto
l3
=
p
.
add_literal
(
3
);
auto
sum1
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l0
,
l3
);
auto
sum2
=
p
.
add_instruction
(
migraphx
::
op
::
add
{},
l0
,
sum1
);
p
.
add_instruction
(
migraphx
::
op
::
add
{},
sum2
,
l3
);
p
.
add_instruction
(
migraphx
::
op
::
identity
{},
l0
);
auto
count
=
std
::
distance
(
p
.
begin
(),
p
.
end
());
p
.
compile
(
dce_target
{});
EXPECT
(
std
::
distance
(
p
.
begin
(),
p
.
end
())
!=
count
);
EXPECT
(
std
::
distance
(
p
.
begin
(),
p
.
end
())
==
2
);
auto
result
=
p
.
eval
({});
EXPECT
(
result
==
migraphx
::
literal
{
0
});
}
int
main
(
int
argc
,
const
char
*
argv
[])
{
test
::
run
(
argc
,
argv
);
}
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