ONE - On-device Neural Engine
Loading...
Searching...
No Matches
mir_onnx::NodeConverterRegistry Class Reference

#include <ONNXNodeConverterRegistry.h>

Public Types

using ConverterFunc = void(*)(const onnx::NodeProto &onnx_node, ConverterContext *context)
 

Public Member Functions

 NodeConverterRegistry ()=default
 
ConverterFunc lookup (const std::string &optype, int64_t opset) const
 
void registerConverter (const std::string &op_type, int64_t opset, ConverterFunc conv)
 

Static Public Member Functions

static NodeConverterRegistrygetInstance ()
 

Detailed Description

Definition at line 60 of file ONNXNodeConverterRegistry.h.

Member Typedef Documentation

◆ ConverterFunc

using mir_onnx::NodeConverterRegistry::ConverterFunc = void (*)(const onnx::NodeProto &onnx_node, ConverterContext *context)

Definition at line 63 of file ONNXNodeConverterRegistry.h.

Constructor & Destructor Documentation

◆ NodeConverterRegistry()

mir_onnx::NodeConverterRegistry::NodeConverterRegistry ( )
default

Member Function Documentation

◆ getInstance()

NodeConverterRegistry & mir_onnx::NodeConverterRegistry::getInstance ( )
static

Definition at line 130 of file ONNXNodeConverterRegistry.cpp.

131{
132 static NodeConverterRegistry instance;
133 return instance;
134}

Referenced by mir_onnx::registerSupportedOps().

◆ lookup()

NodeConverterRegistry::ConverterFunc mir_onnx::NodeConverterRegistry::lookup ( const std::string &  optype,
int64_t  opset 
) const

Definition at line 108 of file ONNXNodeConverterRegistry.cpp.

110{
111 auto it = _converter_map.find(optype);
112 if (it == _converter_map.end())
113 {
114 return nullptr;
115 }
116
117 const VersionMap &conv_map = it->second;
118
119 auto res = std::lower_bound(
120 conv_map.crbegin(), conv_map.crend(), opset,
121 [](const VersionMap::value_type &pair, int64_t opset) { return pair.first > opset; });
122
123 if (res == conv_map.crend())
124 {
125 return nullptr;
126 }
127 return res->second;
128}

◆ registerConverter()

void mir_onnx::NodeConverterRegistry::registerConverter ( const std::string &  op_type,
int64_t  opset,
NodeConverterRegistry::ConverterFunc  conv 
)

Definition at line 136 of file ONNXNodeConverterRegistry.cpp.

138{
139 _converter_map[op_type].emplace(opset, conv);
140}

The documentation for this class was generated from the following files: