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
96f0f567
Commit
96f0f567
authored
Sep 23, 2018
by
Paul
Browse files
Formatting
parent
d3f83759
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
23 deletions
+16
-23
src/include/migraph/matcher.hpp
src/include/migraph/matcher.hpp
+13
-11
test/matcher.cpp
test/matcher.cpp
+3
-12
No files found.
src/include/migraph/matcher.hpp
View file @
96f0f567
...
@@ -186,21 +186,23 @@ matcher_result match_instruction(program& p, instruction_ref ins, M&& m)
...
@@ -186,21 +186,23 @@ matcher_result match_instruction(program& p, instruction_ref ins, M&& m)
return
result
;
return
result
;
}
}
template
<
class
...
Ms
>
template
<
class
...
Ms
>
void
find_matches
(
program
&
p
,
Ms
&&
...
ms
)
void
find_matches
(
program
&
p
,
Ms
&&
...
ms
)
{
{
for
(
auto
ins
:
iterator_for
(
p
))
for
(
auto
ins
:
iterator_for
(
p
))
{
{
bool
match
=
false
;
bool
match
=
false
;
each_args
([
&
](
auto
&&
m
)
{
each_args
(
if
(
match
)
[
&
](
auto
&&
m
)
{
return
;
if
(
match
)
auto
r
=
match_instruction
(
p
,
ins
,
m
.
matcher
());
return
;
if
(
r
.
result
==
p
.
end
())
auto
r
=
match_instruction
(
p
,
ins
,
m
.
matcher
());
return
;
if
(
r
.
result
==
p
.
end
())
m
.
apply
(
r
);
return
;
match
=
true
;
m
.
apply
(
r
);
},
ms
...);
match
=
true
;
},
ms
...);
}
}
}
}
...
...
test/matcher.cpp
View file @
96f0f567
...
@@ -314,24 +314,15 @@ void match_bind1()
...
@@ -314,24 +314,15 @@ void match_bind1()
struct
match_find_sum
struct
match_find_sum
{
{
migraph
::
instruction_ref
ins
;
migraph
::
instruction_ref
ins
;
auto
matcher
()
const
auto
matcher
()
const
{
return
matchers
::
name
(
"sum"
);
}
{
return
matchers
::
name
(
"sum"
);
}
void
apply
(
matchers
::
matcher_result
r
)
const
void
apply
(
matchers
::
matcher_result
r
)
const
{
EXPECT
(
bool
{
r
.
result
==
ins
});
}
{
EXPECT
(
bool
{
r
.
result
==
ins
});
}
};
};
struct
match_find_literal
struct
match_find_literal
{
{
migraph
::
instruction_ref
ins
;
migraph
::
instruction_ref
ins
;
auto
matcher
()
const
auto
matcher
()
const
{
return
matchers
::
name
(
"@literal"
);
}
{
return
matchers
::
name
(
"@literal"
);
}
void
apply
(
matchers
::
matcher_result
r
)
const
void
apply
(
matchers
::
matcher_result
r
)
const
{
{
...
...
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