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
1290f3ba
Commit
1290f3ba
authored
Aug 28, 2019
by
Paul
Browse files
Fix bug in cse pass
parent
015631a1
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
15 additions
and
11 deletions
+15
-11
src/CMakeLists.txt
src/CMakeLists.txt
+1
-1
src/eliminate_common_subexpression.cpp
src/eliminate_common_subexpression.cpp
+7
-3
src/include/migraphx/eliminate_common_subexpression.hpp
src/include/migraphx/eliminate_common_subexpression.hpp
+2
-2
src/targets/gpu/target.cpp
src/targets/gpu/target.cpp
+3
-3
test/eliminate_common_subexpression_test.cpp
test/eliminate_common_subexpression_test.cpp
+2
-2
No files found.
src/CMakeLists.txt
View file @
1290f3ba
...
@@ -4,7 +4,7 @@ include(ROCMPackageConfigHelpers)
...
@@ -4,7 +4,7 @@ include(ROCMPackageConfigHelpers)
add_library
(
migraphx
add_library
(
migraphx
auto_contiguous.cpp
auto_contiguous.cpp
common_subexpression
_elimination
.cpp
eliminate_
common_subexpression.cpp
propagate_constant.cpp
propagate_constant.cpp
dead_code_elimination.cpp
dead_code_elimination.cpp
eliminate_allocation.cpp
eliminate_allocation.cpp
...
...
src/common_subexpression
_elimination
.cpp
→
src/
eliminate_
common_subexpression.cpp
View file @
1290f3ba
#include <migraphx/common_subexpression
_elimination
.hpp>
#include <migraphx/
eliminate_
common_subexpression.hpp>
#include <migraphx/program.hpp>
#include <migraphx/program.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/instruction.hpp>
#include <migraphx/iterator_for.hpp>
#include <migraphx/iterator_for.hpp>
...
@@ -27,13 +27,17 @@ void cse_range(program& p, Range&& r)
...
@@ -27,13 +27,17 @@ void cse_range(program& p, Range&& r)
if
(
*
eq
!=
*
ins
)
if
(
*
eq
!=
*
ins
)
continue
;
continue
;
p
.
replace_instruction
(
ins
,
eq
);
p
.
replace_instruction
(
ins
,
eq
);
cse_range
(
p
,
eq
->
outputs
());
auto
outputs
=
eq
->
outputs
();
std
::
sort
(
outputs
.
begin
(),
outputs
.
end
(),
[
&
](
auto
x
,
auto
y
)
{
return
std
::
distance
(
eq
,
x
)
<
std
::
distance
(
eq
,
y
);
});
cse_range
(
p
,
outputs
);
}
}
instructions
.
emplace
(
ins
->
name
(),
ins
);
instructions
.
emplace
(
ins
->
name
(),
ins
);
}
}
}
}
void
common_subexpression
_elimination
::
apply
(
program
&
p
)
const
{
cse_range
(
p
,
iterator_for
(
p
));
}
void
eliminate_
common_subexpression
::
apply
(
program
&
p
)
const
{
cse_range
(
p
,
iterator_for
(
p
));
}
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace MIGRAPHX_INLINE_NS
}
// namespace migraphx
}
// namespace migraphx
src/include/migraphx/common_subexpression
_elimination
.hpp
→
src/include/migraphx/
eliminate_
common_subexpression.hpp
View file @
1290f3ba
...
@@ -13,9 +13,9 @@ struct program;
...
@@ -13,9 +13,9 @@ struct program;
/**
/**
* Remove identical instructions.
* Remove identical instructions.
*/
*/
struct
common_subexpression
_elimination
struct
eliminate_
common_subexpression
{
{
std
::
string
name
()
const
{
return
"common_subexpression
_elimination
"
;
}
std
::
string
name
()
const
{
return
"
eliminate_
common_subexpression"
;
}
void
apply
(
program
&
p
)
const
;
void
apply
(
program
&
p
)
const
;
};
};
...
...
src/targets/gpu/target.cpp
View file @
1290f3ba
...
@@ -13,7 +13,7 @@
...
@@ -13,7 +13,7 @@
#include <migraphx/simplify_algebra.hpp>
#include <migraphx/simplify_algebra.hpp>
#include <migraphx/propagate_constant.hpp>
#include <migraphx/propagate_constant.hpp>
#include <migraphx/eliminate_contiguous.hpp>
#include <migraphx/eliminate_contiguous.hpp>
#include <migraphx/common_subexpression
_elimination
.hpp>
#include <migraphx/
eliminate_
common_subexpression.hpp>
#include <migraphx/rewrite_batchnorm.hpp>
#include <migraphx/rewrite_batchnorm.hpp>
#include <migraphx/rewrite_rnn.hpp>
#include <migraphx/rewrite_rnn.hpp>
#include <migraphx/rewrite_pooling.hpp>
#include <migraphx/rewrite_pooling.hpp>
...
@@ -49,8 +49,8 @@ std::vector<pass> target::get_passes(migraphx::context& gctx) const
...
@@ -49,8 +49,8 @@ std::vector<pass> target::get_passes(migraphx::context& gctx) const
rewrite_rnn
{},
rewrite_rnn
{},
rewrite_pooling
{},
rewrite_pooling
{},
dead_code_elimination
{},
dead_code_elimination
{},
//
common_subexpression
_elimination
{},
eliminate_
common_subexpression
{},
//
dead_code_elimination{},
dead_code_elimination
{},
simplify_algebra
{},
simplify_algebra
{},
dead_code_elimination
{},
dead_code_elimination
{},
auto_contiguous
{},
auto_contiguous
{},
...
...
test/common_subexpression_
elimination_
test.cpp
→
test/
eliminate_
common_subexpression_test.cpp
View file @
1290f3ba
#include <migraphx/common_subexpression
_elimination
.hpp>
#include <migraphx/
eliminate_
common_subexpression.hpp>
#include <migraphx/dead_code_elimination.hpp>
#include <migraphx/dead_code_elimination.hpp>
#include <migraphx/op/add.hpp>
#include <migraphx/op/add.hpp>
#include <basic_ops.hpp>
#include <basic_ops.hpp>
...
@@ -9,7 +9,7 @@ struct cse_target
...
@@ -9,7 +9,7 @@ struct cse_target
std
::
string
name
()
const
{
return
"dce"
;
}
std
::
string
name
()
const
{
return
"dce"
;
}
std
::
vector
<
migraphx
::
pass
>
get_passes
(
migraphx
::
context
&
)
const
std
::
vector
<
migraphx
::
pass
>
get_passes
(
migraphx
::
context
&
)
const
{
{
return
{
migraphx
::
common_subexpression
_elimination
{},
migraphx
::
dead_code_elimination
{}};
return
{
migraphx
::
eliminate_
common_subexpression
{},
migraphx
::
dead_code_elimination
{}};
}
}
migraphx
::
context
get_context
()
const
{
return
{};
}
migraphx
::
context
get_context
()
const
{
return
{};
}
};
};
...
...
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