| 400 | } |
| 401 | |
| 402 | bool OnnxSerializer::LoadGraph(onnx::ModelProto& model, StaticGraph* graph) |
| 403 | { |
| 404 | const onnx::GraphProto& onnx_graph = model.graph(); |
| 405 | |
| 406 | SetGraphIdentity(graph, model.domain(), onnx_graph.name(), std::to_string(( int )model.model_version())); |
| 407 | |
| 408 | LoadConstTensor(graph, onnx_graph); |
| 409 | CreateInputNode(graph, onnx_graph); |
| 410 | |
| 411 | int i; |
| 412 | std::vector<std::string> no_supported_op; |
| 413 | for(i = 0; i < onnx_graph.node_size(); i++) |
| 414 | { |
| 415 | const onnx::NodeProto& onnx_node = onnx_graph.node(i); |
| 416 | const std::string& onnx_op_name = onnx_node.op_type(); |
| 417 | |
| 418 | if(!FindOpLoadMethod(onnx_op_name)) |
| 419 | { |
| 420 | auto it = find(no_supported_op.begin(),no_supported_op.end(),onnx_op_name); |
| 421 | if(it == no_supported_op.end()) |
| 422 | { |
| 423 | if(onnx_op_name == "Constant") |
| 424 | continue; |
| 425 | no_supported_op.push_back(onnx_op_name); |
| 426 | } |
| 427 | // LOG_ERROR() << "cannot find load function for operator: " << onnx_op_name << "\n"; |
| 428 | // continue; |
| 429 | } |
| 430 | } |
| 431 | if(no_supported_op.size()) |
| 432 | { |
| 433 | |
| 434 | LOG_ERROR() << "These "<<no_supported_op.size() << "op are not supported\n"; |
| 435 | LOG_ERROR() << "{"; |
| 436 | for(int j = 0; j < (int) no_supported_op.size(); j++) |
| 437 | { |
| 438 | LOG_ERROR() << no_supported_op[j] <<","; |
| 439 | } |
| 440 | LOG_ERROR() << "}\n"; |
| 441 | |
| 442 | return false; |
| 443 | } |
| 444 | |
| 445 | for(i = 0; i < onnx_graph.node_size(); i++) |
| 446 | { |
| 447 | const onnx::NodeProto& onnx_node = onnx_graph.node(i); |
| 448 | const std::string& onnx_op_name = onnx_node.op_type(); |
| 449 | |
| 450 | //if(!FindOpLoadMethod(onnx_op_name)) |
| 451 | // { |
| 452 | // LOG_ERROR() << "cannot find load function for operator: " << onnx_op_name << "\n"; |
| 453 | // continue; |
| 454 | // } |
| 455 | if(onnx_op_name == "Constant") |
| 456 | continue; |
| 457 | StaticNode* node = CreateStaticNode(graph, onnx_node.output(0)); |
| 458 | |
| 459 | if(!LoadNode(graph, node, onnx_node)) |
nothing calls this directly
no test coverage detected