"src/vscode:/vscode.git/clone" did not exist on "26277ec5c751e09148a9868e94709b34f4ca6f2f"
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 {
void auto_contiguous::apply(module& m) const
{
std::string key = "require_std_shape";
for(auto ins : reverse_iterator_for(m))
{
auto&& attr = ins->get_operator().attributes();
if((attr.get(key, false)))
// std::string key = "require_std_shape";
// for(auto ins : reverse_iterator_for(m))
// {
// auto&& attr = ins->get_operator().attributes();
// 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 new_args = args;
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;
}
......@@ -53,23 +78,12 @@ void auto_contiguous::apply(module& m) const
{
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")
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);
}
// 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
dead_code_elimination{},
prefuse_ops{},
dead_code_elimination{},
auto_contiguous{},
// auto_contiguous{},
optimize_module{},
auto_contiguous{},
fuse_pointwise{},
dead_code_elimination{},
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