"benchmark/vscode:/vscode.git/clone" did not exist on "9020f7fc3202c6999d4d1d10d7043f92bb045b40"
auto_contiguous.cpp 629 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 {
Paul's avatar
Paul committed
8
inline namespace MIGRAPHX_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();
15
        if(not s.standard() and s.elements() != 0)
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
        }
    }
}

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