builtin.hpp 1.14 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

Paul's avatar
Paul committed
7
namespace migraph {
Paul's avatar
Paul committed
8
9
10

namespace builtin {

Paul's avatar
Paul committed
11
12
struct literal
{
Paul's avatar
Paul committed
13
    std::string name() const { return "@literal"; }
Paul's avatar
Paul committed
14
15
    shape compute_shape(std::vector<shape>) const { MIGRAPH_THROW("builtin"); }
    argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("builtin"); }
Paul's avatar
Paul committed
16
17
};

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

Paul's avatar
Paul committed
26
27
28
struct param
{
    std::string parameter;
Paul's avatar
Paul committed
29
    std::string name() const { return "@param"; }
Paul's avatar
Paul committed
30
31
    shape compute_shape(std::vector<shape>) const { MIGRAPH_THROW("builtin"); }
    argument compute(context&, shape, std::vector<argument>) const { MIGRAPH_THROW("builtin"); }
Paul's avatar
Paul committed
32
    friend std::ostream& operator<<(std::ostream& os, const param& op)
Paul's avatar
Paul committed
33
    {
Paul's avatar
Paul committed
34
        os << op.name() << ":" << op.parameter;
Paul's avatar
Paul committed
35
36
        return os;
    }
Paul's avatar
Paul committed
37
};
Paul's avatar
Paul committed
38

Paul's avatar
Paul committed
39
} // namespace builtin
Paul's avatar
Paul committed
40

Paul's avatar
Paul committed
41
} // namespace migraph
Paul's avatar
Paul committed
42
43

#endif