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
49fa8ed9
Commit
49fa8ed9
authored
Sep 25, 2018
by
Paul
Browse files
Check number of args match in args matcher
parent
0c0032b4
Changes
2
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
7 additions
and
2 deletions
+7
-2
src/include/migraph/matcher.hpp
src/include/migraph/matcher.hpp
+6
-1
test/matcher.cpp
test/matcher.cpp
+1
-1
No files found.
src/include/migraph/matcher.hpp
View file @
49fa8ed9
...
@@ -271,6 +271,11 @@ inline auto name(std::string name)
...
@@ -271,6 +271,11 @@ inline auto name(std::string name)
[
=
,
name
=
std
::
move
(
name
)
](
instruction_ref
ins
)
{
return
ins
->
name
()
==
name
;
});
[
=
,
name
=
std
::
move
(
name
)
](
instruction_ref
ins
)
{
return
ins
->
name
()
==
name
;
});
}
}
inline
auto
nargs
(
std
::
size_t
n
)
{
return
make_basic_pred_matcher
([
=
](
instruction_ref
ins
)
{
return
ins
->
inputs
().
size
()
==
n
;
});
}
inline
auto
arg
(
std
::
size_t
i
)
inline
auto
arg
(
std
::
size_t
i
)
{
{
return
make_basic_fun_matcher
([
=
](
matcher_context
&
ctx
,
instruction_ref
ins
)
{
return
make_basic_fun_matcher
([
=
](
matcher_context
&
ctx
,
instruction_ref
ins
)
{
...
@@ -289,7 +294,7 @@ struct args_impl_ints
...
@@ -289,7 +294,7 @@ struct args_impl_ints
template
<
std
::
size_t
...
Ns
,
class
...
Ms
>
template
<
std
::
size_t
...
Ns
,
class
...
Ms
>
auto
args_impl
(
args_impl_ints
<
Ns
...
>
,
Ms
...
ms
)
auto
args_impl
(
args_impl_ints
<
Ns
...
>
,
Ms
...
ms
)
{
{
return
matchers
::
all_of
(
arg
(
Ns
)(
ms
)...);
return
matchers
::
all_of
(
nargs
(
sizeof
...(
Ns
)),
arg
(
Ns
)(
ms
)...);
}
}
template
<
class
...
Ms
>
template
<
class
...
Ms
>
...
...
test/matcher.cpp
View file @
49fa8ed9
...
@@ -191,7 +191,7 @@ void match_args3()
...
@@ -191,7 +191,7 @@ void match_args3()
auto
m
=
matchers
::
name
(
"sum"
)(
matchers
::
args
(
matchers
::
name
(
"@literal"
)),
auto
m
=
matchers
::
name
(
"sum"
)(
matchers
::
args
(
matchers
::
name
(
"@literal"
)),
matchers
::
standard_shape
());
matchers
::
standard_shape
());
auto
r
=
find_match
(
p
,
m
);
auto
r
=
find_match
(
p
,
m
);
EXPECT
(
bool
{
r
.
result
==
sum
});
EXPECT
(
bool
{
r
.
result
==
p
.
end
()
});
}
}
void
match_args4
()
void
match_args4
()
...
...
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