Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
gaoqiong
MIGraphX
Commits
62c67b45
Commit
62c67b45
authored
Jun 29, 2022
by
Ted Themistokleous
Browse files
Combine negative unit args
parent
013e18cf
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
6 additions
and
21 deletions
+6
-21
src/simplify_algebra.cpp
src/simplify_algebra.cpp
+6
-21
No files found.
src/simplify_algebra.cpp
View file @
62c67b45
...
@@ -874,38 +874,24 @@ struct find_unit_ops
...
@@ -874,38 +874,24 @@ struct find_unit_ops
}
}
};
};
struct
find_neg_unit_
mult_const
struct
find_neg_unit_
ops
{
{
auto
matcher
()
const
auto
matcher
()
const
{
{
return
match
::
name
(
"mul"
)(
auto
mul_neg_1
=
match
::
name
(
"mul"
)(
match
::
either_arg
(
0
,
1
)(
match
::
has_value
(
-
1.0
f
),
match
::
any
().
bind
(
"x"
)));
match
::
either_arg
(
0
,
1
)(
match
::
has_value
(
-
1.0
f
),
match
::
any
().
bind
(
"x"
)));
auto
div_neg_1
=
match
::
name
(
"div"
)(
match
::
args
(
match
::
any
().
bind
(
"x"
),
match
::
has_value
(
-
1.0
f
)));
return
match
::
any_of
(
mul_neg_1
,
div_neg_1
);
}
}
void
apply
(
module
&
m
,
const
match
::
matcher_result
&
r
)
const
void
apply
(
module
&
m
,
const
match
::
matcher_result
&
r
)
const
{
{
auto
ins
=
r
.
result
;
auto
ins
=
r
.
result
;
auto
args
=
ins
->
inputs
();
auto
c_in
=
r
.
instructions
[
"x"
];
auto
c_in
=
r
.
instructions
[
"x"
];
auto
neg
=
m
.
add_instruction
(
make_op
(
"neg"
),
c_in
);
auto
neg
=
m
.
add_instruction
(
make_op
(
"neg"
),
c_in
);
m
.
replace_instruction
(
ins
,
neg
);
m
.
replace_instruction
(
ins
,
neg
);
m
.
replace_instruction
(
ins
,
args
.
front
());
}
};
struct
find_neg_unit_div_const
{
auto
matcher
()
const
{
return
match
::
name
(
"div"
)(
match
::
arg
(
1
)(
match
::
has_value
(
-
1.0
f
)));
}
void
apply
(
module
&
m
,
const
match
::
matcher_result
&
r
)
const
{
auto
ins
=
r
.
result
;
auto
args
=
ins
->
inputs
();
auto
neg
=
m
.
add_instruction
(
make_op
(
"neg"
),
args
.
front
());
m
.
replace_instruction
(
ins
,
neg
);
}
}
};
};
...
@@ -1107,11 +1093,10 @@ void simplify_algebra::apply(module& m) const
...
@@ -1107,11 +1093,10 @@ void simplify_algebra::apply(module& m) const
find_mul_slice_conv
{},
find_mul_slice_conv
{},
find_mul_add
{},
find_mul_add
{},
find_unit_ops
{},
find_unit_ops
{},
find_neg_unit_
div_const
{},
find_neg_unit_
ops
{},
find_div_const
{},
find_div_const
{},
find_sub_const
{},
find_sub_const
{},
find_rsqrt
{},
find_rsqrt
{},
find_neg_unit_mult_const
{},
find_concat_op
{},
find_concat_op
{},
find_split_concat
{},
find_split_concat
{},
find_splits
{},
find_splits
{},
...
...
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