| 340 | #endif |
| 341 | |
| 342 | bool CPURunner::Run(Subgraph* sub_graph) |
| 343 | { |
| 344 | std::vector<Node*>& seq_nodes = sub_graph->seq_nodes; |
| 345 | |
| 346 | #ifdef ENABLE_TIME_PROFILING |
| 347 | ProfRecord* prof = nullptr; |
| 348 | |
| 349 | bool do_prof = false; |
| 350 | |
| 351 | const char* prof_env = std::getenv("PROF_TIME"); |
| 352 | |
| 353 | if(prof_env && prof_env[0] == '1') |
| 354 | { |
| 355 | do_prof = true; |
| 356 | |
| 357 | if(sub_graph->ExistAttr("PROF_TIME")) |
| 358 | prof = any_cast<ProfRecord*>(sub_graph->GetAttr("PROF_TIME")); |
| 359 | else |
| 360 | { |
| 361 | prof = new ProfTime(seq_nodes.size(), parse_node); |
| 362 | sub_graph->SetAttr("PROF_TIME", prof); |
| 363 | } |
| 364 | } |
| 365 | |
| 366 | #endif |
| 367 | bool ret = true; |
| 368 | |
| 369 | sub_graph->Lock(); // sync with graph perf start/stop/get |
| 370 | |
| 371 | GraphPerfStatBuf* p_perf_stat = nullptr; |
| 372 | int perf_record_idx = 0; |
| 373 | |
| 374 | if(sub_graph->ExistAttr(ATTR_GRAPH_PERF_BUFFER)) |
| 375 | { |
| 376 | GraphPerfStatBuf* stat = any_cast<GraphPerfStatBuf>(&sub_graph->GetAttr(ATTR_GRAPH_PERF_BUFFER)); |
| 377 | |
| 378 | if(stat->started) |
| 379 | { |
| 380 | p_perf_stat = stat; |
| 381 | } |
| 382 | } |
| 383 | |
| 384 | for(unsigned int i = 0; i < seq_nodes.size(); i++) |
| 385 | { |
| 386 | Node* node = seq_nodes[i]; |
| 387 | |
| 388 | if(!node->ExistAttr(ATTR_NODE_OPS)) |
| 389 | continue; |
| 390 | |
| 391 | NodeOps* node_ops = any_cast<NodeOps*>(node->GetAttr(ATTR_NODE_OPS)); |
| 392 | |
| 393 | /* dynamic shape process */ |
| 394 | if(node->IsDynamicShape() || node->InputReshaped()) |
| 395 | { |
| 396 | int output_number = node->GetOutputNum(); |
| 397 | |
| 398 | #if 0 |
| 399 | /* free output tensor first */ |