miopen_target.cpp 1.29 KB
Newer Older
Paul's avatar
Paul committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <rtg/miopen/miopen_target.hpp>
#include <rtg/manage_ptr.hpp>

#include <miopen/miopen.h>

namespace rtg { namespace miopen {

using miopen_handle = RTG_MANAGE_PTR(miopenHandle_t, miopenDestroy);
using tensor_descriptor = RTG_MANAGE_PTR(miopenTensorDescriptor_t, miopenDestroyTensorDescriptor);
using convolution_descriptor = RTG_MANAGE_PTR(miopenConvolutionDescriptor_t, miopenDestroyConvolutionDescriptor);
using activation_descriptor = RTG_MANAGE_PTR(miopenActivationDescriptor_t, miopenDestroyActivationDescriptor);

struct miopen_apply
{
    program * prog;

    void apply()
    {
        for(auto it = prog->begin();it != prog->end();it++) {
            if (it->op.name() == "convolution") {
                apply_convolution(it);
            } else if (it->op.name() == "activation") {
                apply_activation(it);
            }
        }
    }

    void apply_convolution(instruction_ref ins)
    {
        // auto&& op = any_cast<convolution>(ins->op);
        // prog->replace_instruction(ins, miopen_convolution{op}, ins->arguments);
    }

    void apply_activation(instruction_ref ins)
    {

    }

};

std::string miopen_target::name() const
{
    return "miopen";
}

void miopen_target::apply(program& p) const
{
    miopen_apply{&p}.apply();
}

} // namespace miopen

} // namespace rtg