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
12d0915e
Commit
12d0915e
authored
Jul 08, 2019
by
Paul
Browse files
Formatting
parent
c10e3bb9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
16 deletions
+17
-16
src/include/migraphx/matcher.hpp
src/include/migraphx/matcher.hpp
+6
-10
src/simplify_algebra.cpp
src/simplify_algebra.cpp
+11
-6
No files found.
src/include/migraphx/matcher.hpp
View file @
12d0915e
...
@@ -240,20 +240,16 @@ void find_matches(program& p, Ms&&... ms)
...
@@ -240,20 +240,16 @@ void find_matches(program& p, Ms&&... ms)
}
}
}
}
template
<
class
M
>
template
<
class
M
>
struct
find_skip
struct
find_skip
{
{
M
m
;
M
m
;
M
matcher
()
const
M
matcher
()
const
{
return
m
;
}
{
return
m
;
}
void
apply
(
program
&
,
matcher_result
)
const
void
apply
(
program
&
,
matcher_result
)
const
{}
{}
};
};
template
<
class
M
>
template
<
class
M
>
find_skip
<
M
>
make_find_skip
(
M
m
)
find_skip
<
M
>
make_find_skip
(
M
m
)
{
{
return
{
m
};
return
{
m
};
...
@@ -330,7 +326,7 @@ const constexpr auto all_of = match_fold_f<lazy_and, true, true>{};
...
@@ -330,7 +326,7 @@ const constexpr auto all_of = match_fold_f<lazy_and, true, true>{};
const
constexpr
auto
any_of
=
match_fold_f
<
lazy_or
,
false
,
true
>
{};
const
constexpr
auto
any_of
=
match_fold_f
<
lazy_or
,
false
,
true
>
{};
const
constexpr
auto
none_of
=
match_fold_f
<
lazy_or
,
false
,
false
>
{};
const
constexpr
auto
none_of
=
match_fold_f
<
lazy_or
,
false
,
false
>
{};
template
<
class
...
Ms
>
template
<
class
...
Ms
>
auto
skip_matches
(
Ms
...
ms
)
auto
skip_matches
(
Ms
...
ms
)
{
{
return
make_find_skip
(
any_of
(
ms
...));
return
make_find_skip
(
any_of
(
ms
...));
...
@@ -398,7 +394,7 @@ MIGRAPHX_PRED_MATCHER(is_constant, instruction_ref ins) { return ins->can_eval()
...
@@ -398,7 +394,7 @@ MIGRAPHX_PRED_MATCHER(is_constant, instruction_ref ins) { return ins->can_eval()
MIGRAPHX_BASIC_MATCHER
(
is_unused
,
matcher_context
&
ctx
,
instruction_ref
ins
)
MIGRAPHX_BASIC_MATCHER
(
is_unused
,
matcher_context
&
ctx
,
instruction_ref
ins
)
{
{
if
(
ins
->
outputs
().
empty
()
and
ins
!=
std
::
prev
(
ctx
.
not_found
()))
if
(
ins
->
outputs
().
empty
()
and
ins
!=
std
::
prev
(
ctx
.
not_found
()))
return
ins
;
return
ins
;
return
ctx
.
not_found
();
return
ctx
.
not_found
();
}
}
...
...
src/simplify_algebra.cpp
View file @
12d0915e
...
@@ -56,11 +56,11 @@ struct find_mul_add
...
@@ -56,11 +56,11 @@ struct find_mul_add
auto
matcher
()
const
auto
matcher
()
const
{
{
return
match
::
name
(
"mul"
)(
match
::
either_arg
(
0
,
1
)(
return
match
::
name
(
"mul"
)(
match
::
either_arg
(
0
,
1
)(
match
::
name
(
"add"
)(
match
::
either_arg
(
0
,
1
)(
match
::
name
(
"add"
)(
match
::
any
().
bind
(
"x"
),
match
::
either_arg
(
0
,
1
)(
match
::
any_of
(
conv_const_weights
(),
match
::
is_constant
()
).
bind
(
"
y"
)
),
match
::
any
(
).
bind
(
"
x"
),
match
::
none_of
(
match
::
args
(
match
::
is_constant
(),
match
::
is_constant
())
)
match
::
any_of
(
conv_const_weights
(),
match
::
is_constant
())
.
bind
(
"y"
)),
),
match
::
none_of
(
match
::
args
(
match
::
is_constant
(),
match
::
is_constant
()))
),
match
::
is_constant
().
bind
(
"a"
)));
match
::
is_constant
().
bind
(
"a"
)));
}
}
...
@@ -139,7 +139,12 @@ void simplify_algebra::apply(program& p) const
...
@@ -139,7 +139,12 @@ void simplify_algebra::apply(program& p) const
{
{
// Run simplifications multiple times
// Run simplifications multiple times
for
(
int
i
=
0
;
i
<
4
;
i
++
)
for
(
int
i
=
0
;
i
<
4
;
i
++
)
match
::
find_matches
(
p
,
match
::
skip_matches
(
match
::
is_unused
(),
match
::
is_constant
()),
find_double_add_lit_broadcast
{},
find_add_lit_broadcast
{},
find_mul_conv
{},
find_mul_add
{});
match
::
find_matches
(
p
,
match
::
skip_matches
(
match
::
is_unused
(),
match
::
is_constant
()),
find_double_add_lit_broadcast
{},
find_add_lit_broadcast
{},
find_mul_conv
{},
find_mul_add
{});
}
}
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace MIGRAPHX_INLINE_NS
...
...
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