aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--tensorflow/tensorboard/components/tf-graph-common/lib/common.ts83
-rw-r--r--tensorflow/tensorboard/components/tf-graph-common/lib/graph.ts9
-rw-r--r--tensorflow/tensorboard/components/tf-graph-common/lib/hierarchy.ts3
-rw-r--r--tensorflow/tensorboard/components/tf-graph-common/lib/parser.ts5
-rw-r--r--tensorflow/tensorboard/components/tf-graph-common/lib/proto.ts107
-rw-r--r--tensorflow/tensorboard/components/tf-graph-common/tf-graph-common.html1
6 files changed, 118 insertions, 90 deletions
diff --git a/tensorflow/tensorboard/components/tf-graph-common/lib/common.ts b/tensorflow/tensorboard/components/tf-graph-common/lib/common.ts
index 4d970f1def..006966f616 100644
--- a/tensorflow/tensorboard/components/tf-graph-common/lib/common.ts
+++ b/tensorflow/tensorboard/components/tf-graph-common/lib/common.ts
@@ -28,87 +28,4 @@ module tf {
setMessage(msg: string): void;
reportError(msg: string, err: Error): void;
}
-
- /**
- * TensorFlow node definition as defined in the graph proto file.
- */
- export interface TFNode {
- /** Name of the node */
- name: string;
- /** List of nodes that are inputs for this node. */
- input: string[];
- /** The name of the device where the computation will run. */
- device: string;
- /** The name of the operation associated with this node. */
- op: string;
- /** List of attributes that describe/modify the operation. */
- attr: {key: string, value: Object}[];
- }
-
- /**
- * TensorFlow stats file definition as defined in the stats proto file.
- */
- export interface StepStats {
- dev_stats: {device: string, node_stats: NodeStats[]}[];
- }
-
- /**
- * TensorFlow stats for a node as defined in the stats proto file.
- */
- export interface NodeStats {
- node_name: string;
- // The next 4 properties are currently stored as string in json
- // and must be parsed.
- all_start_micros: number;
- op_start_rel_micros: number;
- op_end_rel_micros: number;
- all_end_rel_micros: number;
- memory: {
- allocator_name: string;
- total_bytes: number; // Stored as string in json and should be parsed.
- peak_bytes: number; // Stored as string in json and should be parsed.
- }[];
- /** Output sizes recorded for a single execution of a graph node */
- output: TFNodeOutput[];
- timeline_label: string;
- scheduled_micros: string;
- thread_id: string;
- }
-
- /**
- * Description for the output tensor(s) of an operation in the graph.
- */
- export interface TFNodeOutput {
- slot: number; // Stored as string in json and should be parsed.
- tensor_description: {
- /** Data type of tensor elements */
- dtype: string;
- /** Shape of the tensor */
- shape: {
- /**
- * Dimensions of the tensor, such as [{name: 'input', size: 30},
- * {name: 'output', size: 40}] for a 30 x 40 2D tensor. The names
- * are optional. The order of entries in 'dim' matters: It indicates
- * the layout of the values in the tensor in-memory representation.
- */
- dim: {
- /** Size of the tensor in that dimension */
- size: number, // Stored as string in json and should be parsed.
- /** Optional name of the tensor dimension */
- name?: string
- }[];
- };
- /** Information about the size and allocator used for the data */
- allocation_description: {
- // The next 2 properties are stored as string in json and
- // should be parsed.
- /** Total number of bytes requested */
- requested_bytes: number;
- /** Total number of bytes allocated, if known */
- allocated_bytes?: number;
- /** Name of the allocator used */
- allocator_name: string;
- };
- };
- }
} // close module tf
diff --git a/tensorflow/tensorboard/components/tf-graph-common/lib/graph.ts b/tensorflow/tensorboard/components/tf-graph-common/lib/graph.ts
index 4f2c703f41..95401ac360 100644
--- a/tensorflow/tensorboard/components/tf-graph-common/lib/graph.ts
+++ b/tensorflow/tensorboard/components/tf-graph-common/lib/graph.ts
@@ -344,7 +344,7 @@ class OpNodeImpl implements OpNode {
*
* @param rawNode The raw node.
*/
- constructor(rawNode: tf.TFNode) {
+ constructor(rawNode: tf.graph.proto.NodeDef) {
this.op = rawNode.op;
this.name = rawNode.name;
this.device = rawNode.device;
@@ -375,8 +375,8 @@ export function createMetanode(name: string, opt = {}): Metanode {
* Joins the information from the stats file (memory, compute time) with the
* graph information.
*/
-export function joinStatsInfoWithGraph(graph: SlimGraph,
- stats: StepStats): void {
+export function joinStatsInfoWithGraph(
+ graph: SlimGraph, stats: tf.graph.proto.StepStats): void {
_.each(stats.dev_stats, devStats => {
_.each(devStats.node_stats, nodeStats => {
// Lookup the node in the graph by its original name, e.g. A. If not
@@ -824,7 +824,8 @@ function addEdgeToGraph(graph: SlimGraph, inputName: string,
});
}
-export function build(rawNodes: tf.TFNode[], params: BuildParams,
+export function build(
+ rawNodes: tf.graph.proto.NodeDef[], params: BuildParams,
tracker: ProgressTracker): Promise<SlimGraph|void> {
/**
* A dictionary that maps each in-embedding node name to the node
diff --git a/tensorflow/tensorboard/components/tf-graph-common/lib/hierarchy.ts b/tensorflow/tensorboard/components/tf-graph-common/lib/hierarchy.ts
index 687f7af008..222b12e9a5 100644
--- a/tensorflow/tensorboard/components/tf-graph-common/lib/hierarchy.ts
+++ b/tensorflow/tensorboard/components/tf-graph-common/lib/hierarchy.ts
@@ -438,7 +438,8 @@ export function build(graph: tf.graph.SlimGraph, params: HierarchyParams,
.then(() => { return h; });
};
-export function joinAndAggregateStats(h: Hierarchy, stats: StepStats) {
+export function joinAndAggregateStats(
+ h: Hierarchy, stats: tf.graph.proto.StepStats) {
// Get all the possible device names.
let deviceNames = {};
_.each(h.root.leaves(), nodeName => {
diff --git a/tensorflow/tensorboard/components/tf-graph-common/lib/parser.ts b/tensorflow/tensorboard/components/tf-graph-common/lib/parser.ts
index 5680417da4..7bbdd05af3 100644
--- a/tensorflow/tensorboard/components/tf-graph-common/lib/parser.ts
+++ b/tensorflow/tensorboard/components/tf-graph-common/lib/parser.ts
@@ -180,14 +180,15 @@ const METADATA_REPEATED_FIELDS: {[attrPath: string]: boolean} = {
/**
* Parses a blob of proto txt file into a raw Graph object.
*/
-export function parseGraphPbTxt(input: Blob): Promise<TFNode[]> {
+export function parseGraphPbTxt(input: Blob):
+ Promise<tf.graph.proto.NodeDef[]> {
return parsePbtxtFile(input, GRAPH_REPEATED_FIELDS).then(obj => obj['node']);
}
/**
* Parses a blob of proto txt file into a StepStats object.
*/
-function parseStatsPbTxt(input: Blob): Promise<StepStats> {
+function parseStatsPbTxt(input: Blob): Promise<tf.graph.proto.StepStats> {
return parsePbtxtFile(input, METADATA_REPEATED_FIELDS)
.then(obj => obj['step_stats']);
}
diff --git a/tensorflow/tensorboard/components/tf-graph-common/lib/proto.ts b/tensorflow/tensorboard/components/tf-graph-common/lib/proto.ts
new file mode 100644
index 0000000000..5af783677b
--- /dev/null
+++ b/tensorflow/tensorboard/components/tf-graph-common/lib/proto.ts
@@ -0,0 +1,107 @@
+/* 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.
+==============================================================================*/
+
+/**
+ * @fileoverview Interfaces that parallel proto definitions in
+ * third_party/tensorflow/core/framework/...
+ * graph.proto
+ * step_stats.proto
+ * These should stay in sync.
+ */
+module tf.graph.proto {
+ /**
+ * TensorFlow node definition as defined in the graph.proto file.
+ */
+ export interface NodeDef {
+ /** Name of the node */
+ name: string;
+ /** List of nodes that are inputs for this node. */
+ input: string[];
+ /** The name of the device where the computation will run. */
+ device: string;
+ /** The name of the operation associated with this node. */
+ op: string;
+ /** List of attributes that describe/modify the operation. */
+ attr: {key: string, value: Object}[];
+ }
+
+ /**
+ * TensorFlow stats file definition as defined in the stats proto file.
+ */
+ export interface StepStats {
+ dev_stats: {device: string, node_stats: NodeExecStats[]}[];
+ }
+
+ /**
+ * TensorFlow stats for a node as defined in the step_stats proto file.
+ */
+ export interface NodeExecStats {
+ node_name: string;
+ // The next 4 properties are currently stored as string in json
+ // and must be parsed.
+ all_start_micros: number;
+ op_start_rel_micros: number;
+ op_end_rel_micros: number;
+ all_end_rel_micros: number;
+ memory: {
+ allocator_name: string;
+ total_bytes: number; // Stored as string in json and should be parsed.
+ peak_bytes: number; // Stored as string in json and should be parsed.
+ }[];
+ /** Output sizes recorded for a single execution of a graph node */
+ output: NodeOutput[];
+ timeline_label: string;
+ scheduled_micros: string;
+ thread_id: string;
+ }
+
+ /**
+ * Description for the output tensor(s) of an operation in the graph as
+ * defined in the step_stats.proto file.
+ */
+ export interface NodeOutput {
+ slot: number; // Stored as string in json and should be parsed.
+ tensor_description: {
+ /** Data type of tensor elements */
+ dtype: string;
+ /** Shape of the tensor */
+ shape: {
+ /**
+ * Dimensions of the tensor, such as [{name: 'input', size: 30},
+ * {name: 'output', size: 40}] for a 30 x 40 2D tensor. The names
+ * are optional. The order of entries in 'dim' matters: It indicates
+ * the layout of the values in the tensor in-memory representation.
+ */
+ dim: {
+ /** Size of the tensor in that dimension */
+ size: number, // Stored as string in json and should be parsed.
+ /** Optional name of the tensor dimension */
+ name?: string
+ }[];
+ };
+ /** Information about the size and allocator used for the data */
+ allocation_description: {
+ // The next 2 properties are stored as string in json and
+ // should be parsed.
+ /** Total number of bytes requested */
+ requested_bytes: number;
+ /** Total number of bytes allocated, if known */
+ allocated_bytes?: number;
+ /** Name of the allocator used */
+ allocator_name: string;
+ };
+ };
+ }
+}
diff --git a/tensorflow/tensorboard/components/tf-graph-common/tf-graph-common.html b/tensorflow/tensorboard/components/tf-graph-common/tf-graph-common.html
index 7136f8adca..f9c876c649 100644
--- a/tensorflow/tensorboard/components/tf-graph-common/tf-graph-common.html
+++ b/tensorflow/tensorboard/components/tf-graph-common/tf-graph-common.html
@@ -10,6 +10,7 @@
<script src="lib/hierarchy.js"></script>
<script src="lib/layout.js"></script>
<script src="lib/parser.js"></script>
+<script src="lib/proto.js"></script>
<script src="lib/render.js"></script>
<script src="lib/scene/annotation.js"></script>
<script src="lib/scene/contextmenu.js"></script>