partition.cpp 872 Bytes
Newer Older
Paul's avatar
Paul committed
1
2
#include <migraphx/partition.hpp>
#include <migraphx/program.hpp>
Paul's avatar
Update  
Paul committed
3
#include <migraphx/register_op.hpp>
Paul's avatar
Paul committed
4
5
6
7
8
9
10
11
12
13

namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {

struct partition_op
{
    std::string label;
    std::string name() const { return "partition"; }
    // TODO: Implement compute_shape and compute
};
Paul's avatar
Update  
Paul committed
14
MIGRAPHX_REGISTER_OP(partition_op);
Paul's avatar
Paul committed
15

Paul's avatar
Format  
Paul committed
16
17
18
void partition(program& p,
               module& root,
               const std::unordered_map<instruction_ref, std::string>& assignments)
Paul's avatar
Paul committed
19
{
Paul's avatar
Update  
Paul committed
20
    // Group instructions based on label
Paul's avatar
Format  
Paul committed
21

Paul's avatar
Update  
Paul committed
22
    // TODO: Recurse traverse submodule from root
Paul's avatar
Format  
Paul committed
23
    for(auto ins : iterator_for(root))
Paul's avatar
Update  
Paul committed
24
25
26
27
28
29
    {
        // Rough idea of inserting submodules
        std::string label;
        auto sm = p.create_module(label);
        root.add_instruction(partition_op{label}, {}, {sm});
    }
Paul's avatar
Paul committed
30
31
32
33
}

} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx