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
32396d8f
Commit
32396d8f
authored
Oct 12, 2018
by
Paul
Browse files
Formatting
parent
ed49d0c4
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
src/simplify_algebra.cpp
src/simplify_algebra.cpp
+13
-10
No files found.
src/simplify_algebra.cpp
View file @
32396d8f
...
@@ -18,20 +18,22 @@ struct find_add_lit_broadcast
...
@@ -18,20 +18,22 @@ struct find_add_lit_broadcast
}
}
auto
add_lit_broadcast
(
std
::
string
x
,
std
::
string
y
)
const
auto
add_lit_broadcast
(
std
::
string
x
,
std
::
string
y
)
const
{
{
return
match
::
name
(
"add"
)(
match
::
either_arg
(
0
,
1
)(
lit_broadcast
().
bind
(
x
),
not_lit_broadcast
().
bind
(
y
)));
return
match
::
name
(
"add"
)(
match
::
either_arg
(
0
,
1
)(
lit_broadcast
().
bind
(
x
),
not_lit_broadcast
().
bind
(
y
)));
}
}
auto
matcher
()
const
auto
matcher
()
const
{
{
return
match
::
name
(
"add"
)(
match
::
args
(
add_lit_broadcast
(
"a"
,
"x"
),
add_lit_broadcast
(
"b"
,
"y"
)));
return
match
::
name
(
"add"
)(
match
::
args
(
add_lit_broadcast
(
"a"
,
"x"
),
add_lit_broadcast
(
"b"
,
"y"
)));
}
}
void
apply
(
program
&
p
,
match
::
matcher_result
r
)
const
void
apply
(
program
&
p
,
match
::
matcher_result
r
)
const
{
{
auto
ins
=
r
.
result
;
auto
ins
=
r
.
result
;
auto
x_ins
=
r
.
instructions
[
"x"
];
auto
x_ins
=
r
.
instructions
[
"x"
];
auto
y_ins
=
r
.
instructions
[
"y"
];
auto
y_ins
=
r
.
instructions
[
"y"
];
auto
a_ins
=
r
.
instructions
[
"a"
];
auto
a_ins
=
r
.
instructions
[
"a"
];
auto
b_ins
=
r
.
instructions
[
"b"
];
auto
b_ins
=
r
.
instructions
[
"b"
];
if
(
a_ins
->
name
()
!=
b_ins
->
name
())
if
(
a_ins
->
name
()
!=
b_ins
->
name
())
return
;
return
;
...
@@ -41,9 +43,10 @@ struct find_add_lit_broadcast
...
@@ -41,9 +43,10 @@ struct find_add_lit_broadcast
{
{
if
(
a_ins
->
inputs
().
at
(
0
)
->
get_shape
()
!=
b_ins
->
inputs
().
at
(
0
)
->
get_shape
())
if
(
a_ins
->
inputs
().
at
(
0
)
->
get_shape
()
!=
b_ins
->
inputs
().
at
(
0
)
->
get_shape
())
return
;
return
;
auto
op
=
a_ins
->
get_operator
();
auto
op
=
a_ins
->
get_operator
();
auto
presum
=
p
.
insert_instruction
(
ins
,
op
::
add
{},
a_ins
->
inputs
().
at
(
0
),
b_ins
->
inputs
().
at
(
0
));
auto
presum
=
sumab
=
p
.
insert_instruction
(
ins
,
op
,
presum
);
p
.
insert_instruction
(
ins
,
op
::
add
{},
a_ins
->
inputs
().
at
(
0
),
b_ins
->
inputs
().
at
(
0
));
sumab
=
p
.
insert_instruction
(
ins
,
op
,
presum
);
}
}
else
else
{
{
...
...
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