aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/tensorboard/components/tf-graph-common/lib/scene
diff options
context:
space:
mode:
authorGravatar Vijay Vasudevan <vrv@google.com>2015-11-11 18:45:21 -0800
committerGravatar Vijay Vasudevan <vrv@google.com>2015-11-11 18:45:21 -0800
commitf2102f4e2c1c87f1d1bf9ab856a2849c54478760 (patch)
tree54ffdbb4081d6e75d4e626682ea9c70e6866599b /tensorflow/tensorboard/components/tf-graph-common/lib/scene
parent3961abed9560cd852fff4add393b451483bbc3af (diff)
TensorFlow: upstream changes from the afternoon.
Changes: - futurize --stage2 changes for Python 3 compatibility by @girving. - Small updates to documentation by @vrv, schuster and others - Account for failure of std::thread::hardware_concurrency by @ebrevdo. - More changes for backwards-compatibility tests by Josh - Updates to python op doc generation by Josh - Added support for using the best-fit allocator via ConfigProto by @vrv. - Rename LocalSession to DirectSession, since local was a bad name for it. - Enable tf.nn.moments() to work with tensors of unknown shape by @mrry. GITHUB_ISSUE: 139 - Changes for Android build by Andrew. Base CL: 107645181
Diffstat (limited to 'tensorflow/tensorboard/components/tf-graph-common/lib/scene')
-rw-r--r--tensorflow/tensorboard/components/tf-graph-common/lib/scene/node.ts38
1 files changed, 18 insertions, 20 deletions
diff --git a/tensorflow/tensorboard/components/tf-graph-common/lib/scene/node.ts b/tensorflow/tensorboard/components/tf-graph-common/lib/scene/node.ts
index 8c74b37e07..37d409f41a 100644
--- a/tensorflow/tensorboard/components/tf-graph-common/lib/scene/node.ts
+++ b/tensorflow/tensorboard/components/tf-graph-common/lib/scene/node.ts
@@ -411,31 +411,27 @@ function position(nodeGroup, d: render.RenderNodeInformation, sceneBehavior) {
};
/** Enum specifying the options to color nodes by */
-let ColorBy = {
- STRUCTURE: 0,
- DEVICE: 1,
- COMPUTE_TIME: 2,
- MEMORY: 3
-};
+export enum ColorBy { STRUCTURE, DEVICE, COMPUTE_TIME, MEMORY };
/**
* Returns the fill color for the node given its state and the "color by"
* option.
*/
-function getFillForNode(sceneBehavior, colorBy,
+export function getFillForNode(templateIndex, colorBy,
renderInfo: render.RenderNodeInformation, isExpanded: boolean): string {
let colorParams = tf.graph.render.MetanodeColors;
switch (colorBy) {
case ColorBy.STRUCTURE:
if (renderInfo.node.type === tf.graph.NodeType.META) {
let tid = (<Metanode>renderInfo.node).templateId;
- return tid === null ? colorParams.UNKNOWN : colorParams.STRUCTURE_PALETTE(
- sceneBehavior.templateIndex(tid), renderInfo.expanded);
+ return tid === null ?
+ colorParams.UNKNOWN :
+ colorParams.STRUCTURE_PALETTE(templateIndex(tid), isExpanded);
} else if (renderInfo.node.type === tf.graph.NodeType.SERIES) {
// If expanded, we're showing the background rect, which we want to
// appear gray. Otherwise we're showing a stack of ellipses which we
// want to show white.
- return renderInfo.expanded ? colorParams.EXPANDED_COLOR : "white";
+ return isExpanded ? colorParams.EXPANDED_COLOR : "white";
} else if (renderInfo.node.type === NodeType.BRIDGE) {
return renderInfo.structural ? "#f0e" :
(<BridgeNode>renderInfo.node).inbound ? "#0ef" : "#fe0";
@@ -504,22 +500,24 @@ export function stylize(nodeGroup, renderInfo: render.RenderNodeInformation,
// Main node always exists here and it will be reached before subscene,
// so d3 selection is fine here.
let node = nodeGroup.select("." + nodeClass + " ." + Class.Node.COLOR_TARGET);
- let fillColor = getFillForNode(sceneBehavior,
+ let fillColor = getFillForNode(sceneBehavior.templateIndex,
ColorBy[sceneBehavior.colorBy.toUpperCase()],
renderInfo, isExpanded);
node.style("fill", fillColor);
// Choose outline to be darker version of node color if the node is a single
// color and is not selected.
- if (isSelected) {
- node.style("stroke", null);
- } else {
- // If node is colored by a gradient, then use a dark gray outline.
- let outlineColor = fillColor.substring(0, 3) === "url" ?
- tf.graph.render.MetanodeColors.GRADIENT_OUTLINE :
- d3.rgb(fillColor).darker().toString();
- node.style("stroke", outlineColor);
- }
+ node.style("stroke", isSelected ? null : getStrokeForFill(fillColor));
};
+/**
+ * Given a node's fill color/gradient, determine the stroke for the node.
+ */
+export function getStrokeForFill(fill: string) {
+ // If node is colored by a gradient, then use a dark gray outline.
+ return fill.substring(0, 3) === "url" ?
+ tf.graph.render.MetanodeColors.GRADIENT_OUTLINE :
+ d3.rgb(fill).darker().toString();
+}
+
} // close module