"examples/notebooks/utils.py" did not exist on "4c1183c3a88db756f0ef2036c34e04e82554678c"
builtin.hpp 1.66 KB
Newer Older
Paul's avatar
Paul committed
1
2
#ifndef MIGRAPH_GUARD_BUILTIN_HPP
#define MIGRAPH_GUARD_BUILTIN_HPP
Paul's avatar
Paul committed
3

Paul's avatar
Paul committed
4
5
#include <migraph/context.hpp>
#include <migraph/errors.hpp>
Paul's avatar
Paul committed
6
#include <migraph/argument.hpp>
Paul's avatar
Paul committed
7
#include <migraph/reflect.hpp>
8
#include <migraph/config.hpp>
Paul's avatar
Paul committed
9

10
11
namespace migraph {
inline namespace MIGRAPH_INLINE_NS {
Paul's avatar
Paul committed
12
13
14

namespace builtin {

Paul's avatar
Paul committed
15
16
struct literal
{
Paul's avatar
Paul committed
17
    std::string name() const { return "@literal"; }
Paul's avatar
Paul committed
18
    shape compute_shape(const std::vector<shape>&) const { MIGRAPH_THROW("builtin"); }
Paul's avatar
Paul committed
19
20
21
22
    argument compute(context&, const shape&, const std::vector<argument>&) const
    {
        MIGRAPH_THROW("builtin");
    }
Paul's avatar
Paul committed
23
24
};

Paul's avatar
Paul committed
25
26
27
struct outline
{
    shape s;
Paul's avatar
Paul committed
28
29
30
31
32
33
34

    template <class Self, class F>
    static auto reflect(Self& self, F f)
    {
        return pack(f(self.s, "shape"));
    }

Paul's avatar
Paul committed
35
    std::string name() const { return "@outline"; }
Paul's avatar
Paul committed
36
    shape compute_shape(const std::vector<shape>&) const { return s; }
Paul's avatar
Paul committed
37
38
39
40
    argument compute(context&, const shape&, const std::vector<argument>&) const
    {
        MIGRAPH_THROW("builtin");
    }
Paul's avatar
Paul committed
41
42
};

Paul's avatar
Paul committed
43
44
45
struct param
{
    std::string parameter;
Paul's avatar
Paul committed
46
47
48
49
50
51
52

    template <class Self, class F>
    static auto reflect(Self& self, F f)
    {
        return pack(f(self.parameter, "parameter"));
    }

Paul's avatar
Paul committed
53
    std::string name() const { return "@param"; }
Paul's avatar
Paul committed
54
    shape compute_shape(const std::vector<shape>&) const { MIGRAPH_THROW("builtin"); }
Paul's avatar
Paul committed
55
56
57
58
    argument compute(context&, const shape&, const std::vector<argument>&) const
    {
        MIGRAPH_THROW("builtin");
    }
Paul's avatar
Paul committed
59
    friend std::ostream& operator<<(std::ostream& os, const param& op)
Paul's avatar
Paul committed
60
    {
Paul's avatar
Paul committed
61
        os << op.name() << ":" << op.parameter;
Paul's avatar
Paul committed
62
63
        return os;
    }
Paul's avatar
Paul committed
64
};
Paul's avatar
Paul committed
65

Paul's avatar
Paul committed
66
} // namespace builtin
67
} // namespace MIGRAPH_INLINE_NS
Paul's avatar
Paul committed
68
} // namespace migraph
Paul's avatar
Paul committed
69
70

#endif