target.hpp 1.21 KB
Newer Older
Paul's avatar
Paul committed
1
2
#ifndef MIGRAPH_GUARD_MIGRAPHLIB_TARGET_HPP
#define MIGRAPH_GUARD_MIGRAPHLIB_TARGET_HPP
Paul's avatar
Paul committed
3
4
5
6
7
8

#include <string>
#include <functional>
#include <memory>
#include <type_traits>
#include <utility>
Paul's avatar
Paul committed
9
#include <vector>
Paul's avatar
Paul committed
10
#include <migraph/context.hpp>
Paul's avatar
Paul committed
11
#include <migraph/pass.hpp>
Paul's avatar
Paul committed
12

Paul's avatar
Paul committed
13
namespace migraph {
Paul's avatar
Paul committed
14

Paul's avatar
Paul committed
15
16
#if DOXYGEN

Paul's avatar
Paul committed
17
/// An interface for a compilation target
Paul's avatar
Paul committed
18
19
20
21
22
23
24
25
struct target
{
    /// A unique name used to identify the target
    std::string name() const;
    /// The transformation passes to be run
    /**
     * @brief The transformation pass to be run during compilation.
     * @details [long description]
Paul's avatar
Paul committed
26
     *
Paul's avatar
Paul committed
27
28
29
30
31
32
33
34
35
36
37
38
     * @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
39
40
41
42

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

Paul's avatar
Paul committed
48
49
#endif

Paul's avatar
Paul committed
50
} // namespace migraph
Paul's avatar
Paul committed
51
52

#endif