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
580cf447
Commit
580cf447
authored
Apr 02, 2019
by
Paul
Browse files
Use eval for constant propogation
parent
dc85aa6b
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
19 additions
and
1 deletion
+19
-1
src/constant_propagate.cpp
src/constant_propagate.cpp
+19
-1
No files found.
src/constant_propagate.cpp
View file @
580cf447
...
...
@@ -2,6 +2,7 @@
#include <migraphx/program.hpp>
#include <migraphx/matcher.hpp>
#include <migraphx/literal.hpp>
#include <migraphx/functional.hpp>
namespace
migraphx
{
inline
namespace
MIGRAPHX_INLINE_NS
{
...
...
@@ -24,7 +25,24 @@ struct match_const_add
}
};
void
constant_propagate
::
apply
(
program
&
p
)
const
{
match
::
find_matches
(
p
,
match_const_add
{});
}
void
constant_propagate
::
apply
(
program
&
p
)
const
{
fix
([
&
](
auto
self
,
auto
ins
)
{
if
(
not
ins
->
get_shape
().
broadcasted
())
{
auto
r
=
ins
->
eval
();
if
(
not
r
.
empty
())
{
auto
l
=
p
.
add_literal
(
r
.
get_shape
(),
r
.
data
());
p
.
replace_instruction
(
ins
,
l
);
return
;
}
}
auto
children
=
ins
->
inputs
();
for
(
auto
child
:
children
)
self
(
child
);
})(
std
::
prev
(
p
.
end
()));
}
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
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