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
eeb92b57
Commit
eeb92b57
authored
Jul 08, 2019
by
Paul
Browse files
Formatting
parent
c7b4fadd
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
12 deletions
+12
-12
src/simplify_algebra.cpp
src/simplify_algebra.cpp
+12
-12
No files found.
src/simplify_algebra.cpp
View file @
eeb92b57
...
...
@@ -20,16 +20,15 @@ auto op_lit_broadcast(std::string op, std::string x, std::string y)
auto
conv_const_weights
()
{
return
match
::
name
(
"convolution"
)(
match
::
used_once
(),
match
::
args
(
match
::
any
(),
match
::
is_constant
().
bind
(
"w"
)));
match
::
args
(
match
::
any
(),
match
::
is_constant
().
bind
(
"w"
)));
}
struct
find_mul_conv
{
auto
matcher
()
const
{
return
match
::
name
(
"mul"
)(
match
::
either_arg
(
0
,
1
)(
conv_const_weights
().
bind
(
"conv"
),
match
::
name
(
"broadcast"
).
bind
(
"a"
)));
return
match
::
name
(
"mul"
)(
match
::
either_arg
(
0
,
1
)(
conv_const_weights
().
bind
(
"conv"
),
match
::
name
(
"broadcast"
).
bind
(
"a"
)));
}
void
apply
(
program
&
p
,
match
::
matcher_result
r
)
const
...
...
@@ -57,20 +56,21 @@ struct find_mul_add
auto
matcher
()
const
{
return
match
::
name
(
"mul"
)(
match
::
either_arg
(
0
,
1
)(
match
::
name
(
"add"
)(
match
::
either_arg
(
0
,
1
)(
match
::
any
().
bind
(
"x"
),
match
::
any_of
(
conv_const_weights
(),
match
::
is_constant
()).
bind
(
"y"
))),
match
::
is_constant
().
bind
(
"a"
)
));
match
::
name
(
"add"
)(
match
::
either_arg
(
0
,
1
)(
match
::
any
().
bind
(
"x"
),
match
::
any_of
(
conv_const_weights
(),
match
::
is_constant
()).
bind
(
"y"
))),
match
::
is_constant
().
bind
(
"a"
)));
}
void
apply
(
program
&
p
,
match
::
matcher_result
r
)
const
{
auto
ins
=
r
.
result
;
auto
ins
=
r
.
result
;
auto
a_ins
=
r
.
instructions
[
"a"
];
auto
x_ins
=
r
.
instructions
[
"x"
];
auto
y_ins
=
r
.
instructions
[
"y"
];
auto
x_ins
=
r
.
instructions
[
"x"
];
auto
y_ins
=
r
.
instructions
[
"y"
];
auto
xa_ins
=
p
.
insert_instruction
(
ins
,
op
::
mul
{},
x_ins
,
a_ins
);
auto
ya_ins
=
p
.
insert_instruction
(
ins
,
op
::
mul
{},
y_ins
,
a_ins
);
auto
xa_ins
=
p
.
insert_instruction
(
ins
,
op
::
mul
{},
x_ins
,
a_ins
);
auto
ya_ins
=
p
.
insert_instruction
(
ins
,
op
::
mul
{},
y_ins
,
a_ins
);
auto
sum_xa_ya
=
p
.
insert_instruction
(
ins
,
op
::
add
{},
xa_ins
,
ya_ins
);
p
.
replace_instruction
(
ins
,
sum_xa_ya
);
}
...
...
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