| 523 | } |
| 524 | |
| 525 | void DumpOperatorEdges(const Model& model, string* output_file, int op_index) { |
| 526 | // Inputs |
| 527 | const Operator& op = *model.operators[op_index]; |
| 528 | string op_id = GetOpId(op_index); |
| 529 | for (int i = 0; i < op.inputs.size(); i++) { |
| 530 | const auto& input = op.inputs[i]; |
| 531 | if (!model.HasArray(input)) { |
| 532 | // Connected arrays should _always_ exist. Except, perhaps, during |
| 533 | // development. |
| 534 | continue; |
| 535 | } |
| 536 | float log2_buffer_size = GetLog2BufferSize(model, input); |
| 537 | // Draw lines that transport more data thicker (Otherwise, where would the |
| 538 | // data fit? right?). |
| 539 | float line_width = std::max(0.5f, log2_buffer_size / 3.0f); |
| 540 | // Keep edges that transport more data shorter than those with less. |
| 541 | float weight = std::max(1.0f, log2_buffer_size); |
| 542 | if (!IsInputArray(model, input) && |
| 543 | GetOpWithOutput(model, input) == nullptr) { |
| 544 | // Give the main line of data flow a straighter path by penalizing edges |
| 545 | // to standalone buffers. Weights are generally very large buffers that |
| 546 | // would otherwise skew the layout. |
| 547 | weight = 1.0f; |
| 548 | } |
| 549 | string compass_pt = GetArrayCompassPt(model, input); |
| 550 | AppendF(output_file, kInputEdgeFmt, input, compass_pt, op_id, i, line_width, |
| 551 | weight); |
| 552 | } |
| 553 | // Outputs |
| 554 | for (int i = 0; i < op.outputs.size(); i++) { |
| 555 | const auto& output = op.outputs[i]; |
| 556 | if (!model.HasArray(output)) { |
| 557 | continue; |
| 558 | } |
| 559 | float log2_buffer_size = GetLog2BufferSize(model, output); |
| 560 | // See comments above regarding weight and line_width calculations. |
| 561 | float line_width = std::max(0.5f, log2_buffer_size / 3.0f); |
| 562 | float weight = std::max(1.0f, log2_buffer_size); |
| 563 | if (!IsArrayConsumed(model, output)) { |
| 564 | weight = 1.0f; |
| 565 | } |
| 566 | string compass_pt = GetArrayCompassPt(model, output); |
| 567 | AppendF(output_file, kOutputEdgeFmt, op_id, i, output, compass_pt, |
| 568 | line_width, weight); |
| 569 | } |
| 570 | } |
| 571 | |
| 572 | struct Node { |
| 573 | Node() : math_ops(0) {} |
no test coverage detected