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
1cf13681
Commit
1cf13681
authored
Oct 09, 2018
by
Paul
Browse files
Add test for either_arg
parent
8734b6ad
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
48 additions
and
3 deletions
+48
-3
src/targets/gpu/fuse_ops.cpp
src/targets/gpu/fuse_ops.cpp
+5
-3
test/matcher.cpp
test/matcher.cpp
+43
-0
No files found.
src/targets/gpu/fuse_ops.cpp
View file @
1cf13681
...
@@ -252,8 +252,10 @@ struct miopen_conv_bias_relu
...
@@ -252,8 +252,10 @@ struct miopen_conv_bias_relu
template
<
class
...
Ms
>
template
<
class
...
Ms
>
auto
conv_bias
(
Ms
...
ms
)
auto
conv_bias
(
Ms
...
ms
)
{
{
return
match
::
name
(
"gpu::add"
)(
match
::
either_arg
(
0
,
1
)(
match
::
arg
(
0
)(
bias_shape
(
match
::
output
())).
bind
(
"bias"
),
return
match
::
name
(
"gpu::add"
)(
fusable_conv
(
match
::
output
()).
bind
(
"conv"
)),
match
::
output
(),
match
::
either_arg
(
0
,
1
)(
match
::
arg
(
0
)(
bias_shape
(
match
::
output
())).
bind
(
"bias"
),
fusable_conv
(
match
::
output
()).
bind
(
"conv"
)),
match
::
output
(),
ms
...);
ms
...);
}
}
...
...
test/matcher.cpp
View file @
1cf13681
...
@@ -239,6 +239,45 @@ void match_args7()
...
@@ -239,6 +239,45 @@ void match_args7()
EXPECT
(
bool
{
r
.
result
==
pass
});
EXPECT
(
bool
{
r
.
result
==
pass
});
}
}
void
match_either_args1
()
{
migraph
::
program
p
;
auto
one
=
p
.
add_literal
(
1
);
auto
two
=
p
.
add_literal
(
2
);
auto
sum1
=
p
.
add_instruction
(
sum_op
{},
one
,
two
);
auto
sum2
=
p
.
add_instruction
(
sum_op
{},
sum1
,
two
);
p
.
add_instruction
(
pass_op
{},
sum2
);
auto
m
=
match
::
name
(
"sum"
)(
match
::
either_arg
(
0
,
1
)(
match
::
name
(
"sum"
),
match
::
name
(
"@literal"
)));
auto
r
=
find_match
(
p
,
m
);
EXPECT
(
bool
{
r
.
result
==
sum2
});
}
void
match_either_args2
()
{
migraph
::
program
p
;
auto
one
=
p
.
add_literal
(
1
);
auto
two
=
p
.
add_literal
(
2
);
auto
sum1
=
p
.
add_instruction
(
sum_op
{},
one
,
two
);
auto
sum2
=
p
.
add_instruction
(
sum_op
{},
sum1
,
two
);
p
.
add_instruction
(
pass_op
{},
sum2
);
auto
m
=
match
::
name
(
"sum"
)(
match
::
either_arg
(
0
,
1
)(
match
::
name
(
"@literal"
),
match
::
name
(
"sum"
)));
auto
r
=
find_match
(
p
,
m
);
EXPECT
(
bool
{
r
.
result
==
sum2
});
}
void
match_either_args3
()
{
migraph
::
program
p
;
auto
one
=
p
.
add_literal
(
1
);
auto
two
=
p
.
add_literal
(
2
);
auto
sum1
=
p
.
add_instruction
(
sum_op
{},
one
,
two
);
auto
sum2
=
p
.
add_instruction
(
sum_op
{},
sum1
,
two
);
p
.
add_instruction
(
pass_op
{},
sum2
);
auto
m
=
match
::
name
(
"sum"
)(
match
::
either_arg
(
0
,
1
)(
match
::
name
(
"pass"
),
match
::
name
(
"@literal"
)));
auto
r
=
find_match
(
p
,
m
);
EXPECT
(
bool
{
r
.
result
==
p
.
end
()});
}
void
match_all_of1
()
void
match_all_of1
()
{
{
migraph
::
program
p
;
migraph
::
program
p
;
...
@@ -391,6 +430,10 @@ int main()
...
@@ -391,6 +430,10 @@ int main()
match_args6
();
match_args6
();
match_args7
();
match_args7
();
match_either_args1
();
match_either_args2
();
match_either_args3
();
match_all_of1
();
match_all_of1
();
match_all_of2
();
match_all_of2
();
...
...
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