aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/tensorboard/components/tf-graph-common/lib/scene
diff options
context:
space:
mode:
authorGravatar Vijay Vasudevan <vrv@google.com>2015-12-02 15:04:40 -0800
committerGravatar Vijay Vasudevan <vrv@google.com>2015-12-02 15:04:40 -0800
commitbf6b536bde7d8060c489b51fedb58968b8cbfd7c (patch)
treeabdafce531563adae9a811d8994477f020979dec /tensorflow/tensorboard/components/tf-graph-common/lib/scene
parentfa095c5db0ac9cfe2328a19b32ae208e58e3746a (diff)
TensorFlow: Upstream changes to git.
Change 109240606 Fix typo Change 109240358 Fix bug in Concat's shape inference due to legacy scalar handling. The shape function was inadvertently converting outputs of unknown shape (rank=None) to vectors of unknown length (rank=1), due to inability to distinguish between legacy scalars and vectors, because `max(1, None)` is 1. Change 109237152 Remove numarray requirement in python_config. Change 109234003 Fix typo in elu documentation. Change 109232946 Python must now be configured via ./configure script Change 109232134 Backported fixes to the tensor comparison operators from the public Eigen repository Change 109231761 Test invalid inputs to softmax_cross_entropy_with_logits. Change 109230218 Backported fixes to the tensor comparison operators from the public Eigen repository Change 109229915 Correct comments in seq2seq to show the right input types for embedding models. (Thanks to hugman@github for bringing this up.) Change 109229118 Fix resize_images example in documentation and allow resize_images to run on a single image with partially-known shape. Change 109228940 Fix demo and node add/remove button spacing Change 109227909 Include Elu in the NN docs. Change 109227059 Adds variable_op_scope and makes variable_scope always add a name_scope. This creates an op scope for variables that makes it easy to create independent operations with a default name by making that name unique for the current scope and it allows explicit names that are not made unique. Change 109224492 Streamline yuv -> rgb conversion to be done in one pass in native code. The entire process now takes ~2ms (including the ByteBuffer.get() calls), down from 10+ ms when the arrays were being interleaved in Java prior to conversion. Also abstracting common yuv->rgb color conversion into helper method. Change 109224389 Add ability to move nodes in and out of auxiliary nodes in graph. Change 109217177 Update generated Op docs. Change 109215030 Implementation of the ELU activation function: http://arxiv.org/abs/1511.07289 Change 109209848 When GPUBFCAllocator runs out of memory, also log a summary of chunks in use by size. Change 109206569 Switched to the public version of the Eigen::sign method since it supports complex numbers. Change 109199813 Modify tensorflow.SequenceExample to support multiple-length sequences. Base CL: 109241553
Diffstat (limited to 'tensorflow/tensorboard/components/tf-graph-common/lib/scene')
-rw-r--r--tensorflow/tensorboard/components/tf-graph-common/lib/scene/annotation.ts10
-rw-r--r--tensorflow/tensorboard/components/tf-graph-common/lib/scene/contextmenu.ts77
-rw-r--r--tensorflow/tensorboard/components/tf-graph-common/lib/scene/node.ts30
3 files changed, 111 insertions, 6 deletions
diff --git a/tensorflow/tensorboard/components/tf-graph-common/lib/scene/annotation.ts b/tensorflow/tensorboard/components/tf-graph-common/lib/scene/annotation.ts
index 6823d8b48c..d973f75fd3 100644
--- a/tensorflow/tensorboard/components/tf-graph-common/lib/scene/annotation.ts
+++ b/tensorflow/tensorboard/components/tf-graph-common/lib/scene/annotation.ts
@@ -17,6 +17,7 @@ limitations under the License.
/// <reference path="../render.ts" />
/// <reference path="scene.ts" />
/// <reference path="edge.ts" />
+/// <reference path="contextmenu.ts" />
module tf.graph.scene.annotation {
@@ -90,7 +91,7 @@ export function buildGroup(container, annotationData: render.AnnotationList,
let aGroup = d3.select(this);
update(aGroup, d, a, sceneBehavior);
if (a.annotationType !== tf.graph.render.AnnotationType.ELLIPSIS) {
- addInteraction(aGroup, d, sceneBehavior);
+ addInteraction(aGroup, d, a, sceneBehavior);
}
});
@@ -151,7 +152,7 @@ function addAnnotationLabel(aGroup, label, a, additionalClassNames,
}
function addInteraction(selection, d: render.RenderNodeInformation,
- sceneBehavior) {
+ annotation: tf.graph.render.Annotation, sceneBehavior) {
selection
.on("mouseover", a => {
sceneBehavior.fire("annotation-highlight", {
@@ -174,6 +175,11 @@ function addInteraction(selection, d: render.RenderNodeInformation,
hostName: d.node.name
});
});
+ if (annotation.annotationType !== tf.graph.render.AnnotationType.SUMMARY &&
+ annotation.annotationType !== tf.graph.render.AnnotationType.CONSTANT) {
+ selection.on("contextmenu", tf.graph.scene.contextmenu.getMenu(
+ tf.graph.scene.node.getContextMenu(annotation.node, sceneBehavior)));
+ }
};
/**
diff --git a/tensorflow/tensorboard/components/tf-graph-common/lib/scene/contextmenu.ts b/tensorflow/tensorboard/components/tf-graph-common/lib/scene/contextmenu.ts
new file mode 100644
index 0000000000..648f3461fe
--- /dev/null
+++ b/tensorflow/tensorboard/components/tf-graph-common/lib/scene/contextmenu.ts
@@ -0,0 +1,77 @@
+/* Copyright 2015 Google Inc. All Rights Reserved.
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+==============================================================================*/
+
+module tf.graph.scene.contextmenu {
+
+/** Function that converts data to a title string. */
+export interface TitleFunction {
+ (data: any): string;
+}
+
+/** Function that takes action based on item clicked in the context menu. */
+export interface ActionFunction {
+ (elem: any, d: any, i: number): void;
+}
+
+/**
+ * The interface for an item in the context menu
+ */
+export interface ContextMenuItem {
+ title: TitleFunction;
+ action: ActionFunction;
+}
+
+/**
+ * Returns the event listener, which can be used as an argument for the d3
+ * selection.on function. Renders the context menu that is to be displayed
+ * in response to the event.
+ */
+export function getMenu(menu: ContextMenuItem[]) {
+ let menuSelection = d3.select(".context-menu");
+ // Close the menu when anything else is clicked.
+ d3.select("body").on("click.context", function() {
+ menuSelection.style("display", "none");
+ });
+
+ // Function called to populate the context menu.
+ return function(data, index: number): void {
+ // Position and display the menu.
+ let event = <MouseEvent>d3.event;
+ menuSelection.style({
+ "display": "block",
+ "left": (event.layerX + 1) + "px",
+ "top": (event.layerY + 1) + "px"
+ });
+
+ // Stop the event from propagating further.
+ event.preventDefault();
+ event.stopPropagation();
+
+ // Add provided items to the context menu.
+ menuSelection.html("");
+ let list = menuSelection.append("ul");
+ list.selectAll("li").data(menu).enter()
+ .append("li")
+ .html(function(d) {
+ return d.title(data);
+ })
+ .on("click", (d, i) => {
+ d.action(this, data, index);
+ menuSelection.style("display", "none");
+ });
+ };
+};
+
+} // close module
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 57496ceffb..bb1d1fdcdc 100644
--- a/tensorflow/tensorboard/components/tf-graph-common/lib/scene/node.ts
+++ b/tensorflow/tensorboard/components/tf-graph-common/lib/scene/node.ts
@@ -16,6 +16,7 @@ limitations under the License.
/// <reference path="../graph.ts" />
/// <reference path="scene.ts" />
/// <reference path="annotation.ts" />
+/// <reference path="contextmenu.ts" />
module tf.graph.scene.node {
@@ -229,32 +230,53 @@ function addInteraction(selection, d: render.RenderNodeInformation,
selection.attr("pointer-events", "none");
return;
}
+
+ let contextMenuFunction = tf.graph.scene.contextmenu.getMenu(
+ getContextMenu(d.node, sceneBehavior));
selection.on("dblclick", d => {
- sceneBehavior.fire("node-toggle-expand", { name: d.node.name });
+ sceneBehavior.fire("node-toggle-expand", { name: d.node.name });
})
.on("mouseover", d => {
// don't send mouseover over expanded group,
// otherwise it is causing too much glitches
- if (sceneBehavior.isNodeExpanded(d)) { return; }
+ if (sceneBehavior.isNodeExpanded(d)) { return; }
sceneBehavior.fire("node-highlight", { name: d.node.name });
})
.on("mouseout", d => {
// don't send mouseover over expanded group,
// otherwise it is causing too much glitches
- if (sceneBehavior.isNodeExpanded(d)) { return; }
+ if (sceneBehavior.isNodeExpanded(d)) { return; }
- sceneBehavior.fire("node-unhighlight", { name: d.node.name });
+ sceneBehavior.fire("node-unhighlight", { name: d.node.name });
})
.on("click", d => {
// Stop this event's propagation so that it isn't also considered
// a graph-select.
(<Event>d3.event).stopPropagation();
sceneBehavior.fire("node-select", { name: d.node.name });
+ })
+ .on("contextmenu", (d, i) => {
+ sceneBehavior.fire("node-select", { name: d.node.name });
+ contextMenuFunction.call(d, i);
});
};
/**
+ * Returns the d3 context menu specification for the provided node.
+ */
+export function getContextMenu(node: Node, sceneBehavior) {
+ return [{
+ title: d => {
+ return tf.graph.getIncludeNodeButtonString(node.include);
+ },
+ action: (elm, d, i) => {
+ sceneBehavior.fire("node-toggle-extract", { name: node.name });
+ }
+ }];
+}
+
+/**
* Append svg text for label and assign data.
* @param nodeGroup
* @param renderNodeInfo The render node information for the label.