auto_contiguous.cpp 528 Bytes
Newer Older
Paul's avatar
Paul committed
1
2
3
4
5
6
7
8
#include <migraph/auto_contiguous.hpp>
#include <migraph/program.hpp>
#include <migraph/instruction.hpp>
#include <migraph/operators.hpp>
#include <migraph/iterator_for.hpp>

namespace migraph {

Paul's avatar
Paul committed
9
void auto_contiguous::apply(program& p) const
Paul's avatar
Paul committed
10
11
12
{
    for(auto ins : iterator_for(p))
    {
Paul's avatar
Paul committed
13
        shape s = ins->get_shape();
Paul's avatar
Paul committed
14
        if(not s.standard())
Paul's avatar
Paul committed
15
        {
16
            auto c = p.insert_instruction(std::next(ins), op::contiguous{}, ins);
Paul's avatar
Paul committed
17
            p.replace_instruction(ins, c);
Paul's avatar
Paul committed
18
19
20
21
22
        }
    }
}

} // namespace migraph