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
eb507459
Commit
eb507459
authored
Mar 05, 2019
by
Paul
Browse files
Add more test cases
parent
8c1231e8
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
78 additions
and
4 deletions
+78
-4
test/include/test.hpp
test/include/test.hpp
+3
-4
test/schedule_test.cpp
test/schedule_test.cpp
+75
-0
No files found.
test/include/test.hpp
View file @
eb507459
...
@@ -39,13 +39,12 @@ inline std::ostream& operator<<(std::ostream& s, std::nullptr_t)
...
@@ -39,13 +39,12 @@ inline std::ostream& operator<<(std::ostream& s, std::nullptr_t)
template
<
class
T
>
template
<
class
T
>
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
s
,
const
std
::
vector
<
T
>&
v
)
inline
std
::
ostream
&
operator
<<
(
std
::
ostream
&
s
,
const
std
::
vector
<
T
>&
v
)
{
{
char
delim
=
'{'
;
s
<<
"{ "
;
for
(
auto
&&
x
:
v
)
for
(
auto
&&
x
:
v
)
{
{
s
<<
delim
<<
" "
<<
x
;
s
<<
x
<<
", "
;
delim
=
','
;
}
}
s
<<
"
}"
;
s
<<
"}"
;
return
s
;
return
s
;
}
}
...
...
test/schedule_test.cpp
View file @
eb507459
...
@@ -133,6 +133,27 @@ void check_conflicts(migraphx::program& p,
...
@@ -133,6 +133,27 @@ void check_conflicts(migraphx::program& p,
});
});
}
}
template
<
class
T
>
std
::
vector
<
T
>
sorted
(
std
::
vector
<
T
>
x
)
{
std
::
sort
(
x
.
begin
(),
x
.
end
());
return
x
;
}
template
<
class
T
>
std
::
vector
<
T
>
unique
(
std
::
vector
<
T
>
x
)
{
std
::
sort
(
x
.
begin
(),
x
.
end
());
x
.
erase
(
std
::
unique
(
x
.
begin
(),
x
.
end
()),
x
.
end
());
return
x
;
}
std
::
vector
<
std
::
size_t
>
get_wait_for
(
std
::
vector
<
std
::
size_t
>
wait_for
)
{
std
::
sort
(
wait_for
.
begin
(),
wait_for
.
end
());
return
wait_for
;
}
std
::
vector
<
std
::
size_t
>
get_wait_for
(
std
::
size_t
wait_on
,
std
::
vector
<
std
::
size_t
>
wait_for
)
std
::
vector
<
std
::
size_t
>
get_wait_for
(
std
::
size_t
wait_on
,
std
::
vector
<
std
::
size_t
>
wait_for
)
{
{
wait_for
.
erase
(
std
::
find
(
wait_for
.
begin
(),
wait_for
.
end
(),
wait_on
));
wait_for
.
erase
(
std
::
find
(
wait_for
.
begin
(),
wait_for
.
end
(),
wait_on
));
...
@@ -179,6 +200,42 @@ TEST_CASE(single_entry)
...
@@ -179,6 +200,42 @@ TEST_CASE(single_entry)
EXPECT
(
check_conflicts
(
p
,
onep1
,
onep2
));
EXPECT
(
check_conflicts
(
p
,
onep1
,
onep2
));
}
}
TEST_CASE
(
zero_merge1
)
{
instruction_map
stream
;
migraphx
::
program
p
;
auto
one
=
p
.
add_literal
(
1
);
auto
onep1
=
p
.
add_instruction
(
unary_op
{},
one
);
auto
onep2
=
p
.
add_instruction
(
unary_op
{},
one
);
auto
binary
=
p
.
add_instruction
(
migraphx
::
op
::
identity
{},
onep1
,
onep2
);
p
.
compile
(
schedule_target
{
&
stream
});
EXPECT
(
stream
.
count
(
one
)
==
0
);
EXPECT
(
stream
.
at
(
onep1
)
!=
stream
.
at
(
onep2
));
// No stream assignment
EXPECT
(
stream
.
count
(
binary
)
==
0
);
// There is no wait
EXPECT
(
get_wait_for
(
binary
).
empty
());
EXPECT
(
check_conflicts
(
p
,
onep1
,
onep2
));
}
TEST_CASE
(
zero_merge2
)
{
instruction_map
stream
;
migraphx
::
program
p
;
auto
one
=
p
.
add_literal
(
1
);
auto
onep1
=
p
.
add_instruction
(
unary_op
{},
one
);
auto
onep2
=
p
.
add_instruction
(
unary_op
{},
one
);
auto
binary
=
p
.
add_instruction
(
migraphx
::
op
::
identity
{},
p
.
add_instruction
(
migraphx
::
op
::
identity
{},
onep1
),
p
.
add_instruction
(
migraphx
::
op
::
identity
{},
onep2
));
p
.
compile
(
schedule_target
{
&
stream
});
EXPECT
(
stream
.
count
(
one
)
==
0
);
EXPECT
(
stream
.
at
(
onep1
)
!=
stream
.
at
(
onep2
));
// No stream assignment
EXPECT
(
stream
.
count
(
binary
)
==
0
);
// There is no wait
EXPECT
(
get_wait_for
(
binary
).
empty
());
EXPECT
(
check_conflicts
(
p
,
onep1
,
onep2
));
}
TEST_CASE
(
double_entry
)
TEST_CASE
(
double_entry
)
{
{
instruction_map
stream
;
instruction_map
stream
;
...
@@ -271,6 +328,24 @@ TEST_CASE(five_branches)
...
@@ -271,6 +328,24 @@ TEST_CASE(five_branches)
check_conflicts
(
p
,
{
c1
,
c2
,
c3
,
{
i1
}});
check_conflicts
(
p
,
{
c1
,
c2
,
c3
,
{
i1
}});
}
}
TEST_CASE
(
four_branches_eq
)
{
instruction_map
stream
;
migraphx
::
program
p
;
auto
one
=
p
.
add_literal
(
1
);
auto
onep1
=
p
.
add_instruction
(
unary_op
{},
one
);
auto
onep2
=
p
.
add_instruction
(
unary_op
{},
one
);
auto
onep3
=
p
.
add_instruction
(
unary_op
{},
one
);
auto
onep4
=
p
.
add_instruction
(
unary_op
{},
one
);
auto
binary
=
p
.
add_instruction
(
nary_op
{},
onep1
,
onep2
,
onep3
,
onep4
);
p
.
compile
(
schedule_target
{
&
stream
});
EXPECT
(
stream
.
count
(
one
)
==
0
);
EXPECT
(
sorted
<
std
::
size_t
>
({
stream
.
at
(
onep1
),
stream
.
at
(
onep2
),
stream
.
at
(
onep3
),
stream
.
at
(
onep4
)})
==
unique
<
std
::
size_t
>
({
stream
.
at
(
onep1
),
stream
.
at
(
onep2
),
stream
.
at
(
onep3
),
stream
.
at
(
onep4
)}));
EXPECT
(
stream
.
at
(
binary
)
==
0
);
EXPECT
(
get_wait_for
(
binary
)
==
get_wait_for
(
stream
[
binary
],
{
stream
[
onep1
],
stream
[
onep2
],
stream
[
onep3
],
stream
[
onep4
]}));
check_conflicts
(
p
,
{{
onep1
},
{
onep2
},
{
onep3
},
{
onep4
}});
}
TEST_CASE
(
seq_merge
)
TEST_CASE
(
seq_merge
)
{
{
instruction_map
stream
;
instruction_map
stream
;
...
...
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