target.hpp 1.26 KB
Newer Older
Paul's avatar
Paul committed
1
2
#ifndef MIGRAPHX_GUARD_MIGRAPHLIB_TARGET_HPP
#define MIGRAPHX_GUARD_MIGRAPHLIB_TARGET_HPP
Paul's avatar
Paul committed
3

Paul's avatar
Paul committed
4
#include <cassert>
Paul's avatar
Paul committed
5
6
7
8
9
#include <string>
#include <functional>
#include <memory>
#include <type_traits>
#include <utility>
Paul's avatar
Paul committed
10
#include <vector>
Paul's avatar
Paul committed
11
12
#include <migraphx/context.hpp>
#include <migraphx/pass.hpp>
Paul's avatar
Paul committed
13
#include <migraphx/config.hpp>
Paul's avatar
Paul committed
14

Paul's avatar
Paul committed
15
namespace migraphx {
Paul's avatar
Paul committed
16
inline namespace MIGRAPHX_INLINE_NS {
Paul's avatar
Paul committed
17

Paul's avatar
Paul committed
18
#ifdef DOXYGEN
Paul's avatar
Paul committed
19

Paul's avatar
Paul committed
20
/// An interface for a compilation target
Paul's avatar
Paul committed
21
22
23
24
25
26
struct target
{
    /// A unique name used to identify the target
    std::string name() const;
    /**
     * @brief The transformation pass to be run during compilation.
Paul's avatar
Paul committed
27
     *
Paul's avatar
Paul committed
28
29
30
31
32
33
34
35
36
37
38
39
     * @param ctx This is the target-dependent context that is created by `get_context`
     * @return The passes to be ran
     */
    std::vector<pass> get_passes(context& ctx) const;
    /**
     * @brief Construct a context for the target.
     * @return The context to be used during compilation and execution.
     */
    context get_context() const;
};

#else
Paul's avatar
Paul committed
40
41
42
43

<%
interface('target',
    virtual('name', returns='std::string', const=True),
Paul's avatar
Paul committed
44
    virtual('get_passes', ctx='context&', returns='std::vector<pass>', const=True),
Paul's avatar
Paul committed
45
    virtual('get_context', returns='context', const=True)
Paul's avatar
Paul committed
46
47
48
)
%>

Paul's avatar
Paul committed
49
50
#endif

Paul's avatar
Paul committed
51
} // namespace MIGRAPHX_INLINE_NS
Paul's avatar
Paul committed
52
} // namespace migraphx
Paul's avatar
Paul committed
53
54

#endif