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

Paul's avatar
Paul committed
7
namespace migraphx {
8
inline namespace MIGRAPH_INLINE_NS {
Paul's avatar
Paul committed
9

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

23
} // namespace MIGRAPH_INLINE_NS
Paul's avatar
Paul committed
24
} // namespace migraphx