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
029d227a
Commit
029d227a
authored
May 01, 2019
by
Paul
Browse files
Traverse down instead of up for const propogation
parent
5b68eced
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
25 additions
and
14 deletions
+25
-14
src/propagate_constant.cpp
src/propagate_constant.cpp
+25
-14
No files found.
src/propagate_constant.cpp
View file @
029d227a
...
@@ -22,22 +22,33 @@ bool skip_propogate(instruction_ref ins)
...
@@ -22,22 +22,33 @@ bool skip_propogate(instruction_ref ins)
void
propagate_constant
::
apply
(
program
&
p
)
const
void
propagate_constant
::
apply
(
program
&
p
)
const
{
{
fix
([
&
](
auto
self
,
auto
ins
)
{
for
(
auto
i
:
iterator_for
(
p
))
if
(
not
skip_propogate
(
ins
))
{
{
if
(
i
->
name
()
!=
"@literal"
)
auto
r
=
ins
->
eval
();
continue
;
if
(
not
r
.
empty
())
if
(
i
->
outputs
().
empty
())
continue
;
fix
([
&
](
auto
self
,
auto
ins
)
{
std
::
unordered_set
<
instruction_ref
>
children
(
ins
->
outputs
().
begin
(),
ins
->
outputs
().
end
());
for
(
auto
child
:
children
)
{
{
assert
(
r
.
get_shape
()
==
ins
->
get_shape
());
if
(
not
skip_propogate
(
child
))
auto
l
=
p
.
add_literal
(
r
.
get_shape
(),
r
.
data
());
{
p
.
replace_instruction
(
ins
,
l
);
auto
r
=
child
->
eval
();
return
;
if
(
not
r
.
empty
())
{
assert
(
r
.
get_shape
()
==
child
->
get_shape
());
auto
l
=
p
.
add_literal
(
r
.
get_shape
(),
r
.
data
());
self
(
p
.
replace_instruction
(
child
,
l
));
}
}
else
{
self
(
child
);
}
}
}
}
})(
i
);
std
::
unordered_set
<
instruction_ref
>
children
(
ins
->
inputs
().
begin
(),
ins
->
inputs
().
end
());
}
for
(
auto
child
:
children
)
self
(
child
);
})(
std
::
prev
(
p
.
end
()));
}
}
}
// 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