31 static const char *names[] = {
32#define CIRCLE_NODE(OPCODE, CIRCLE_CLASS) #CIRCLE_CLASS,
33#define CIRCLE_VNODE(OPCODE, CIRCLE_CLASS) #CIRCLE_CLASS,
34#include <luci/IR/CircleNodes.lst>
39 auto const node_name = names[
static_cast<int>(opcode)];
41 assert(std::string(node_name).substr(0, 6) ==
"Circle");
45 return std::string(node_name).substr(6);
53#define CIRCLE_NODE(OPCODE, CLASS) CLASS,
54#define CIRCLE_VNODE(OPCODE, CLASS) CLASS,
61#include <luci/IR/CircleNodes.lst>
82#define REGISTER_KERNEL(name) \
83 register_kernel_builder(BuilderId::Circle##name, build_kernel_Circle##name);
85#include "KernelsToBuild.lst"
92 return _operator_builders.at(
size_t(opcode));
96 std::vector<KernelBuilderFunc *> _operator_builders;
102 assert(
size_t(
id) < _operator_builders.size());
103 _operator_builders[size_t(
id)] = func;
108 const std::unordered_map<const loco::Graph *, RuntimeGraph *> &graph_to_runtime_graph,
109 const std::unordered_map<const loco::Node *, Tensor *> &node_to_tensor)
112 _builder_registry = std::make_unique<KernelBuilderRegistry>();
123 auto specific_builder = _builder_registry->get_kernel_builder_func(node->
opcode());
124 if (specific_builder !=
nullptr)
125 return specific_builder(node, *
this);
127 std::string msg =
"Unsupported operator: ";
128 msg += toString(node->
opcode()) +
" in " + std::string(node->
name());
129 throw std::invalid_argument(msg.c_str());
KernelBuilder(const std::unordered_map< const loco::Graph *, RuntimeGraph * > &graph_to_runtime_graph, const std::unordered_map< const loco::Node *, Tensor * > &node_to_tensor)
std::unique_ptr< Kernel > build(const luci::CircleNode *node)
Registry of kernel builders.
std::unique_ptr< Kernel >(const luci::CircleNode *, KernelBuilderHelper &) KernelBuilderFunc
KernelBuilderFunc * get_kernel_builder_func(luci::CircleOpcode opcode) const
const std::string toString(luci::CircleOpcode opcode)
NodeName name(void) const
virtual CircleOpcode opcode(void) const =0