17#ifndef __MOCO_FRONTEND_ONNX_GRAPH_BUILDER_REGISTRY_H__
18#define __MOCO_FRONTEND_ONNX_GRAPH_BUILDER_REGISTRY_H__
41 if (_builder_map.find(op) == _builder_map.end())
44 return _builder_map.at(op).get();
54 void add(
const std::string op, std::unique_ptr<GraphBuilder> &&builder)
56 _builder_map[op] = std::move(builder);
60 std::map<const std::string, std::unique_ptr<GraphBuilder>> _builder_map;
68#define REGISTER_OP_BUILDER(NAME, BUILDER) \
71 __attribute__((constructor)) void reg_op(void) \
73 std::unique_ptr<moco::onnx::BUILDER> builder = std::make_unique<moco::onnx::BUILDER>(); \
74 moco::onnx::GraphBuilderRegistry::get().add(#NAME, std::move(builder)); \
Parent class of onnx operation graph builders.
Class to return graph builder for passed onnx Operator.
static GraphBuilderRegistry & get()
void add(const std::string op, std::unique_ptr< GraphBuilder > &&builder)
const GraphBuilder * lookup(const std::string &op) const
Returns registered GraphBuilder pointer for operator or nullptr if not registered.