"docs/vscode:/vscode.git/clone" did not exist on "edb6eb86437d8f1c8df3d509d6e507e466742978"
register_op.cpp 803 Bytes
Newer Older
1
#include <migraphx/register_op.hpp>
2
#include <migraphx/ranges.hpp>
3
4
5
6
7
8
9
#include <unordered_map>

namespace migraphx {
inline namespace MIGRAPHX_INLINE_NS {

std::unordered_map<std::string, operation>& op_map()
{
10
    static std::unordered_map<std::string, operation> m; // NOLINT
11
12
13
    return m;
}
void register_op(const operation& op) { op_map()[op.name()] = op; }
14
15
operation load_op(const std::string& name)
{
16
    return at(op_map(), name, "Operator not found: " + name);
17
}
18
19
20
21
22
23
24
25
26
27
28
29
30

std::vector<std::string> get_operators()
{
    std::vector<std::string> result;
    std::transform(op_map().begin(), op_map().end(), std::back_inserter(result), [&](auto&& p) {
        return p.first;
    });
    std::sort(result.begin(), result.end());
    return result;
}

} // namespace MIGRAPHX_INLINE_NS
} // namespace migraphx