MCPcopy Create free account
hub / github.com/tensorflow/tensorboard / buildShape

Function buildShape

tensorboard/plugins/graph/tf_graph_common/node.ts:556–627  ·  view source on GitHub ↗
(
  nodeGroup,
  d,
  nodeClass: string
)

Source from the content-addressed store, hash-verified

554 * @return Selection of the shape.
555 */
556export function buildShape(
557 nodeGroup,
558 d,
559 nodeClass: string
560): d3.Selection<any, any, any, any> {
561 // Create a group to house the underlying visual elements.
562 let shapeGroup = tf_graph_common.selectOrCreateChild(
563 nodeGroup,
564 'g',
565 nodeClass
566 );
567 // TODO: DOM structure should be templated in HTML somewhere, not JS.
568 switch (d.node.type) {
569 case NodeType.OP:
570 const opNode = d.node as OpNode;
571 if (
572 _.isNumber(opNode.functionInputIndex) ||
573 _.isNumber(opNode.functionOutputIndex)
574 ) {
575 // This is input or output arg for a TensorFlow function. Use a special
576 // shape (a triangle) for them.
577 tf_graph_common.selectOrCreateChild(
578 shapeGroup,
579 'polygon',
580 Class.Node.COLOR_TARGET
581 );
582 break;
583 }
584 tf_graph_common.selectOrCreateChild(
585 shapeGroup,
586 'ellipse',
587 Class.Node.COLOR_TARGET
588 );
589 break;
590 case NodeType.SERIES:
591 // Choose the correct stamp to use to represent this series.
592 let stampType = 'annotation';
593 let groupNodeInfo = <render.RenderGroupNodeInfo>d;
594 if (groupNodeInfo.coreGraph) {
595 stampType = groupNodeInfo.node.hasNonControlEdges
596 ? 'vertical'
597 : 'horizontal';
598 }
599 let classList = [Class.Node.COLOR_TARGET];
600 if (groupNodeInfo.isFadedOut) {
601 classList.push('faded-ellipse');
602 }
603 tf_graph_common
604 .selectOrCreateChild(shapeGroup, 'use', classList)
605 .attr('xlink:href', '#op-series-' + stampType + '-stamp');
606 tf_graph_common
607 .selectOrCreateChild(shapeGroup, 'rect', Class.Node.COLOR_TARGET)
608 .attr('rx', d.radius)
609 .attr('ry', d.radius);
610 break;
611 case NodeType.BRIDGE:
612 tf_graph_common
613 .selectOrCreateChild(shapeGroup, 'rect', Class.Node.COLOR_TARGET)

Callers 2

buildGroupFunction · 0.85
buildShapeForAnnotationFunction · 0.85

Calls 1

pushMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…