| 197 | } |
| 198 | |
| 199 | int NodeSetParamGeneric(void* node, const char* param_name, const char* type_name, const void* param_val, int size) |
| 200 | { |
| 201 | Node* real_node = ( Node* )node; |
| 202 | |
| 203 | Operator* op = real_node->GetOp(); |
| 204 | |
| 205 | if(op->SetParamItem(param_name, type_name, param_val)) |
| 206 | return 0; |
| 207 | |
| 208 | /* check custom attr */ |
| 209 | if(!real_node->ExistAttr(ATTR_CUSTOM_ATTR)) |
| 210 | { |
| 211 | set_tengine_errno(ENOENT); |
| 212 | return -1; |
| 213 | } |
| 214 | |
| 215 | node_custom_attr_map_t* attr_map = any_cast<node_custom_attr_map_t>(&real_node->GetAttr(ATTR_CUSTOM_ATTR)); |
| 216 | |
| 217 | if(attr_map->count(param_name) == 0) |
| 218 | { |
| 219 | set_tengine_errno(ENOENT); |
| 220 | return -1; |
| 221 | } |
| 222 | |
| 223 | CustomNodeAttr* attr_entry = &attr_map->at(param_name); |
| 224 | |
| 225 | if((size != attr_entry->attr_size) || |
| 226 | (type_name && attr_entry->type_name && strcmp(type_name, attr_entry->type_name))) |
| 227 | { |
| 228 | set_tengine_errno(EINVAL); |
| 229 | return -1; |
| 230 | } |
| 231 | |
| 232 | attr_entry->mem.resize(size); |
| 233 | |
| 234 | void* data = attr_entry->mem.data(); |
| 235 | |
| 236 | memcpy(data, param_val, size); |
| 237 | |
| 238 | return 0; |
| 239 | } |
| 240 | |
| 241 | } // namespace TEngine |
no test coverage detected