"vscode:/vscode.git/clone" did not exist on "79e6abbda83015921a6bdf5affd6582ba0ffea7a"
auto_contiguous.cpp 591 Bytes
Newer Older
Paul's avatar
Paul committed
1
2
3
4
5
6
7
#include <migraph/auto_contiguous.hpp>
#include <migraph/program.hpp>
#include <migraph/instruction.hpp>
#include <migraph/operators.hpp>
#include <migraph/iterator_for.hpp>

namespace migraph {
8
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 migraph