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

Function NodeGetParamGeneric

core/lib/node.cpp:159–197  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

157}
158
159int NodeGetParamGeneric(void* node, const char* param_name, const char* type_name, void* param_val, int size)
160{
161 Node* real_node = ( Node* )node;
162
163 Operator* op = real_node->GetOp();
164
165 if(op->GetParamItem(param_name, type_name, param_val))
166 return 0;
167
168 /* check custom attr */
169 if(!real_node->ExistAttr(ATTR_CUSTOM_ATTR))
170 {
171 set_tengine_errno(ENOENT);
172 return -1;
173 }
174
175 node_custom_attr_map_t* attr_map = any_cast<node_custom_attr_map_t>(&real_node->GetAttr(ATTR_CUSTOM_ATTR));
176
177 if(attr_map->count(param_name) == 0)
178 {
179 set_tengine_errno(ENOENT);
180 return -1;
181 }
182
183 CustomNodeAttr* attr_entry = &attr_map->at(param_name);
184
185 if((size != attr_entry->attr_size) ||
186 (type_name && attr_entry->type_name && strcmp(type_name, attr_entry->type_name)))
187 {
188 set_tengine_errno(EINVAL);
189 return -1;
190 }
191
192 void* data = attr_entry->mem.data();
193
194 memcpy(param_val, data, size);
195
196 return 0;
197}
198
199int NodeSetParamGeneric(void* node, const char* param_name, const char* type_name, const void* param_val, int size)
200{

Callers 1

node_get_attr_genericFunction · 0.85

Calls 6

set_tengine_errnoFunction · 0.85
GetOpMethod · 0.80
GetParamItemMethod · 0.45
ExistAttrMethod · 0.45
GetAttrMethod · 0.45
dataMethod · 0.45

Tested by

no test coverage detected