auto_contiguous.cpp 550 Bytes
Newer Older
Paul's avatar
Paul committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
#include <migraph/auto_contiguous.hpp>
#include <migraph/program.hpp>
#include <migraph/instruction.hpp>
#include <migraph/operators.hpp>
#include <migraph/iterator_for.hpp>

namespace migraph {

void auto_contigous::apply(program& p) const
{
    for(auto ins : iterator_for(p))
    {
        shape s = ins->result;
        if(not s.packed() or s.broadcasted())
        {
            auto prev = p.insert_instruction(ins, ins->op, ins->arguments);
            p.replace_instruction(ins, contiguous{}, prev);
        }
    }
}

} // namespace migraph