"examples/research_projects/colossalai/requirement.txt" did not exist on "f1b726e46e7a66771e6321d00a28048effce1389"
register_op.cpp 879 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
bool has_op(const std::string& name) { return op_map().count(name) == 1; }

21
22
23
24
25
26
27
28
29
30
31
32
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