Commit 0ac5a5d5 authored by Khalique Ahmed's avatar Khalique Ahmed
Browse files

changed auto contiguous to no longer check shape, move after optimize_module

parent e46a6a52
...@@ -33,16 +33,41 @@ inline namespace MIGRAPHX_INLINE_NS { ...@@ -33,16 +33,41 @@ inline namespace MIGRAPHX_INLINE_NS {
void auto_contiguous::apply(module& m) const void auto_contiguous::apply(module& m) const
{ {
std::string key = "require_std_shape"; // std::string key = "require_std_shape";
for(auto ins : reverse_iterator_for(m)) // for(auto ins : reverse_iterator_for(m))
{ // {
auto&& attr = ins->get_operator().attributes(); // auto&& attr = ins->get_operator().attributes();
if((attr.get(key, false))) // if((attr.get(key, false)))
// {
// auto args = ins->inputs();
// auto new_args = args;
// std::transform(args.begin(), args.end(), new_args.begin(), [&](auto in) {
// if(in->name() == "contiguous")
// {
// return in;
// }
// return m.insert_instruction(ins, make_op("contiguous"), in);
// });
// if(new_args != args)
// {
// m.replace_instruction(ins, ins->get_operator(), new_args);
// }
// }
// }
auto last = std::prev(m.end());
for(auto ins : iterator_for(m))
{ {
if(ins->name() == "layout" or ins->name() == "contiguous")
continue;
// for last instruction that is NOT a return
if(ins->outputs().empty() and ins != last)
continue;
auto args = ins->inputs(); auto args = ins->inputs();
auto new_args = args; auto new_args = args;
std::transform(args.begin(), args.end(), new_args.begin(), [&](auto in) { std::transform(args.begin(), args.end(), new_args.begin(), [&](auto in) {
if(in->name() == "contiguous") if(in->name() == "contiguous" or in->name() == "layout")
{ {
return in; return in;
} }
...@@ -53,23 +78,12 @@ void auto_contiguous::apply(module& m) const ...@@ -53,23 +78,12 @@ void auto_contiguous::apply(module& m) const
{ {
m.replace_instruction(ins, ins->get_operator(), new_args); m.replace_instruction(ins, ins->get_operator(), new_args);
} }
} // shape s = ins->get_shape();
} // if(not s.dynamic() and not s.standard() and s.elements() != 0)
// {
auto last = std::prev(m.end()); // auto c = m.insert_instruction(std::next(ins), make_op("contiguous"), ins);
for(auto ins : iterator_for(m)) // m.replace_instruction(ins, c);
{ // }
if(ins->name() == "layout")
continue;
// for last instruction that is NOT a return
if(ins->outputs().empty() and ins != last)
continue;
shape s = ins->get_shape();
if(not s.dynamic() and not s.standard() and s.elements() != 0)
{
auto c = m.insert_instruction(std::next(ins), make_op("contiguous"), ins);
m.replace_instruction(ins, c);
}
} }
} }
......
...@@ -132,8 +132,9 @@ std::vector<pass> target::get_passes(migraphx::context& gctx, const compile_opti ...@@ -132,8 +132,9 @@ std::vector<pass> target::get_passes(migraphx::context& gctx, const compile_opti
dead_code_elimination{}, dead_code_elimination{},
prefuse_ops{}, prefuse_ops{},
dead_code_elimination{}, dead_code_elimination{},
auto_contiguous{}, // auto_contiguous{},
optimize_module{}, optimize_module{},
auto_contiguous{},
fuse_pointwise{}, fuse_pointwise{},
dead_code_elimination{}, dead_code_elimination{},
enable_pass(not enabled(MIGRAPHX_DISABLE_REDUCE_FUSION{}), fuse_reduce{}), enable_pass(not enabled(MIGRAPHX_DISABLE_REDUCE_FUSION{}), fuse_reduce{}),
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment