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

Function getFillForNode

tensorboard/plugins/graph/tf_graph_common/node.ts:779–866  ·  view source on GitHub ↗
(
  templateIndex: (name: string) => number | null,
  colorBy: ColorBy,
  renderInfo: render.RenderNodeInfo,
  isExpanded: boolean,
  svgRoot?: SVGElement
)

Source from the content-addressed store, hash-verified

777 * for the fill inside the svgRoot when necessary.
778 */
779export function getFillForNode(
780 templateIndex: (name: string) => number | null,
781 colorBy: ColorBy,
782 renderInfo: render.RenderNodeInfo,
783 isExpanded: boolean,
784 svgRoot?: SVGElement
785): string {
786 let colorParams = render.MetanodeColors;
787 templateIndex = templateIndex || (() => 0);
788 switch (colorBy) {
789 // The 'none' mode still colors nodes, just ignores the template structural
790 // colors.
791 case ColorBy.NONE:
792 case ColorBy.STRUCTURE:
793 if (renderInfo.node.type === NodeType.META) {
794 let tid = (<Metanode>renderInfo.node).templateId;
795 return colorBy === ColorBy.STRUCTURE && tid !== null
796 ? colorParams.STRUCTURE_PALETTE(templateIndex(tid)!, isExpanded)
797 : colorParams.UNKNOWN;
798 } else if (renderInfo.node.type === NodeType.SERIES) {
799 // If expanded, we're showing the background rect, which we want to
800 // appear gray. Otherwise we're showing a stack of ellipses which we
801 // want to show white.
802 return isExpanded ? colorParams.EXPANDED_COLOR : 'white';
803 } else if (renderInfo.node.type === NodeType.BRIDGE) {
804 return renderInfo.structural
805 ? '#f0e'
806 : (<BridgeNode>renderInfo.node).inbound
807 ? '#0ef'
808 : '#fe0';
809 } else if (_.isNumber((renderInfo.node as OpNode).functionInputIndex)) {
810 // This is an input of a TensorFlow function.
811 return '#795548';
812 } else if (_.isNumber((renderInfo.node as OpNode).functionOutputIndex)) {
813 // This is an output of a TensorFlow function.
814 return '#009688';
815 } else {
816 // Op nodes are white.
817 return 'white';
818 }
819 case ColorBy.DEVICE:
820 if (renderInfo.deviceColors == null) {
821 // Return the hue for unknown device.
822 return colorParams.UNKNOWN;
823 }
824 return isExpanded
825 ? colorParams.EXPANDED_COLOR
826 : getGradient(
827 'device-' + renderInfo.node.name,
828 renderInfo.deviceColors,
829 svgRoot
830 );
831 case ColorBy.XLA_CLUSTER:
832 if (renderInfo.xlaClusterColors == null) {
833 // Return the hue for unknown xlaCluster.
834 return colorParams.UNKNOWN;
835 }
836 return isExpanded

Callers 1

stylizeFunction · 0.85

Calls 1

getGradientFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…