MCPcopy Create free account
hub / github.com/OAID/Tengine / BindOps

Function BindOps

executor/lib/custom_kernel.cpp:156–195  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

154}
155
156NodeOps* BindOps(Node* node, const std::string& dev_name)
157{
158 CustomKernelList* k_list = any_cast<CustomKernelList>(&node->GetAttr(ATTR_CUSTOM_KERNEL));
159
160 struct custom_kernel_ops* ops = k_list->GetKernel(dev_name.c_str());
161
162 if(ops == nullptr)
163 {
164 /* try if there is any device support setting */
165 ops = k_list->GetKernel(ANY_DEVICE_NAME);
166
167 if(ops == nullptr)
168 return nullptr;
169 }
170
171 Operator* op = node->GetOp();
172
173 if(op->GetName() != "Generic" && (op->GetName() != ops->op))
174 {
175 XLOG_WARN() << "unmatched op: custom " << ops->op << " real " << op->GetName() << "\n";
176 return nullptr;
177 }
178
179 /* check bind */
180 if(ops->bind != nullptr && !CheckBind(node, ops))
181 {
182 if(ops->force)
183 {
184 LOG_ERROR() << "bind custom kernel for node: " << node->GetName() << " failed, but force is set\n";
185
186 set_tengine_errno(ENOTRECOVERABLE);
187 }
188
189 return nullptr;
190 }
191
192 NodeOps* node_ops = CustomKernelNodeOps::NewOps(node, ops);
193
194 return node_ops;
195}
196
197} // namespace CustomKernelManager
198

Callers 1

BindCustomKernelMethod · 0.85

Calls 7

CheckBindFunction · 0.85
set_tengine_errnoFunction · 0.85
GetOpMethod · 0.80
GetNameMethod · 0.80
GetAttrMethod · 0.45
GetKernelMethod · 0.45
c_strMethod · 0.45

Tested by

no test coverage detected