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
f1f9770b
Commit
f1f9770b
authored
Mar 09, 2019
by
Paul
Browse files
Dont add all inputs as conflicts
parent
8a081fcf
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
16 additions
and
13 deletions
+16
-13
src/dead_code_elimination.cpp
src/dead_code_elimination.cpp
+2
-3
src/schedule.cpp
src/schedule.cpp
+7
-4
test/schedule_test.cpp
test/schedule_test.cpp
+7
-6
No files found.
src/dead_code_elimination.cpp
View file @
f1f9770b
...
@@ -41,9 +41,8 @@ void dead_code_elimination::apply(program& p) const
...
@@ -41,9 +41,8 @@ void dead_code_elimination::apply(program& p) const
// Skip the last instruction
// Skip the last instruction
if
(
i
==
last
)
if
(
i
==
last
)
break
;
break
;
// Skip instruction with empty shape as output unless its a builtin or undefined
// Skip instruction with empty shape as output unless its a builtin or undefined or identity
if
(
i
->
get_shape
().
elements
()
==
0
and
not
(
i
->
name
().
front
()
==
'@'
)
and
if
(
i
->
get_shape
().
elements
()
==
0
and
i
->
name
().
front
()
!=
'@'
and
i
->
name
()
!=
"undefined"
and
i
->
name
()
!=
"identity"
)
not
(
i
->
name
()
==
"undefined"
))
continue
;
continue
;
assert
(
bidistance
(
p
,
i
,
last
)
>
0
);
assert
(
bidistance
(
p
,
i
,
last
)
>
0
);
fix
([
&
](
auto
self
,
auto
leaf
)
{
fix
([
&
](
auto
self
,
auto
leaf
)
{
...
...
src/schedule.cpp
View file @
f1f9770b
...
@@ -274,7 +274,13 @@ struct stream_info
...
@@ -274,7 +274,13 @@ struct stream_info
{
{
if
(
result
[
merge
].
size
()
<=
stream
)
if
(
result
[
merge
].
size
()
<=
stream
)
result
[
merge
].
resize
(
stream
+
1
);
result
[
merge
].
resize
(
stream
+
1
);
result
[
merge
][
stream
].
push_back
(
ins
);
auto
&&
r
=
result
[
merge
][
stream
];
r
.
push_back
(
ins
);
// Copy inputs if they dont have a stream(and are not a builtin and context free)
// Inputs without a stream can have a implicit dependency
std
::
copy_if
(
ins
->
inputs
().
begin
(),
ins
->
inputs
().
end
(),
std
::
back_inserter
(
r
),
[
&
](
auto
x
)
{
return
not
this
->
has_stream
(
x
)
and
not
is_context_free
(
x
->
get_operator
())
and
x
->
name
().
front
()
!=
'@'
;
});
}
}
}
}
}
}
...
@@ -380,9 +386,6 @@ void schedule::apply(program& p) const
...
@@ -380,9 +386,6 @@ void schedule::apply(program& p) const
{
{
auto
args
=
merge
.
second
[
j
];
auto
args
=
merge
.
second
[
j
];
args
.
insert
(
args
.
begin
(),
ins1
);
args
.
insert
(
args
.
begin
(),
ins1
);
// Add input arguments as a conflict
for
(
auto
arg
:
merge
.
second
[
j
])
args
.
insert
(
args
.
end
(),
arg
->
inputs
().
begin
(),
arg
->
inputs
().
end
());
p
.
insert_instruction
(
merge
.
first
,
op
::
identity
{},
args
);
p
.
insert_instruction
(
merge
.
first
,
op
::
identity
{},
args
);
}
}
});
});
...
...
test/schedule_test.cpp
View file @
f1f9770b
...
@@ -240,9 +240,9 @@ TEST_CASE(zero_record)
...
@@ -240,9 +240,9 @@ TEST_CASE(zero_record)
auto
one
=
p
.
add_literal
(
1
);
auto
one
=
p
.
add_literal
(
1
);
auto
onep1
=
p
.
add_instruction
(
unary_op
{},
one
);
auto
onep1
=
p
.
add_instruction
(
unary_op
{},
one
);
auto
onep2
=
p
.
add_instruction
(
unary_op
{},
one
);
auto
onep2
=
p
.
add_instruction
(
unary_op
{},
one
);
auto
binary
=
p
.
add_instruction
(
nary_op
{},
auto
onei1
=
p
.
add_instruction
(
migraphx
::
op
::
identity
{},
onep1
);
p
.
add_instruction
(
migraphx
::
op
::
identity
{},
onep
1
),
auto
onei2
=
p
.
add_instruction
(
migraphx
::
op
::
identity
{},
onep
2
);
p
.
add_instruction
(
migraphx
::
op
::
identity
{},
onep2
)
);
auto
binary
=
p
.
add_instruction
(
nary_op
{},
onei1
,
onei2
);
p
.
compile
(
t
);
p
.
compile
(
t
);
EXPECT
(
not
t
.
has_stream
(
one
));
EXPECT
(
not
t
.
has_stream
(
one
));
EXPECT
(
t
.
get_stream
(
onep1
)
!=
t
.
get_stream
(
onep2
));
EXPECT
(
t
.
get_stream
(
onep1
)
!=
t
.
get_stream
(
onep2
));
...
@@ -250,6 +250,7 @@ TEST_CASE(zero_record)
...
@@ -250,6 +250,7 @@ TEST_CASE(zero_record)
EXPECT
(
get_wait_for
(
binary
)
==
EXPECT
(
get_wait_for
(
binary
)
==
get_wait_for
(
t
.
get_stream
(
binary
),
{
t
.
get_stream
(
onep1
),
t
.
get_stream
(
onep2
)}));
get_wait_for
(
t
.
get_stream
(
binary
),
{
t
.
get_stream
(
onep1
),
t
.
get_stream
(
onep2
)}));
EXPECT
(
check_conflicts
(
p
,
onep1
,
onep2
));
EXPECT
(
check_conflicts
(
p
,
onep1
,
onep2
));
check_conflicts
(
p
,
{{
onep1
,
onei1
},
{
onep2
,
onei2
}});
}
}
TEST_CASE
(
zero_merge1
)
TEST_CASE
(
zero_merge1
)
...
@@ -342,8 +343,8 @@ TEST_CASE(double_entry)
...
@@ -342,8 +343,8 @@ TEST_CASE(double_entry)
{
{
schedule_target
t
{};
schedule_target
t
{};
migraphx
::
program
p
;
migraphx
::
program
p
;
auto
one
=
p
.
add_literal
(
1
);
auto
one
=
p
.
add_instruction
(
migraphx
::
op
::
identity
{},
p
.
add_literal
(
1
)
)
;
auto
two
=
p
.
add_literal
(
2
);
auto
two
=
p
.
add_instruction
(
migraphx
::
op
::
identity
{},
p
.
add_literal
(
2
)
)
;
auto
onep
=
p
.
add_instruction
(
unary_op
{},
one
);
auto
onep
=
p
.
add_instruction
(
unary_op
{},
one
);
auto
twop
=
p
.
add_instruction
(
unary_op
{},
two
);
auto
twop
=
p
.
add_instruction
(
unary_op
{},
two
);
auto
binary
=
p
.
add_instruction
(
nary_op
{},
onep
,
twop
);
auto
binary
=
p
.
add_instruction
(
nary_op
{},
onep
,
twop
);
...
@@ -354,7 +355,7 @@ TEST_CASE(double_entry)
...
@@ -354,7 +355,7 @@ TEST_CASE(double_entry)
EXPECT
(
t
.
get_stream
(
binary
)
==
0
);
EXPECT
(
t
.
get_stream
(
binary
)
==
0
);
EXPECT
(
get_wait_for
(
binary
)
==
EXPECT
(
get_wait_for
(
binary
)
==
get_wait_for
(
t
.
get_stream
(
binary
),
{
t
.
get_stream
(
onep
),
t
.
get_stream
(
twop
)}));
get_wait_for
(
t
.
get_stream
(
binary
),
{
t
.
get_stream
(
onep
),
t
.
get_stream
(
twop
)}));
EXPECT
(
check_conflicts
(
p
,
onep
,
twop
)
);
check_conflicts
(
p
,
{{
onep
,
one
},
{
twop
,
two
}}
);
}
}
TEST_CASE
(
two_branches
)
TEST_CASE
(
two_branches
)
...
...
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