target.hpp 1.23 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

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
#include <migraph/context.hpp>
Paul's avatar
Paul committed
12
#include <migraph/pass.hpp>
Paul's avatar
Paul committed
13

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

Paul's avatar
Paul committed
16
#ifdef DOXYGEN
Paul's avatar
Paul committed
17

Paul's avatar
Paul committed
18
/// An interface for a compilation target
Paul's avatar
Paul committed
19
20
21
22
23
24
25
26
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
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 migraph
Paul's avatar
Paul committed
52
53

#endif