aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/tensorboard/components/tf_graph_board/tf-graph-board.html
blob: 0ee694e1e6638f7ed8808f5d11a5c92d9ae6673f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
<!--
@license
Copyright 2016 The TensorFlow Authors. 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.
-->

<link rel="import" href="../polymer/polymer.html">
<link rel="import" href="../tf-graph/tf-graph.html">
<link rel="import" href="../tf-graph-common/tf-graph-common.html">
<link rel="import" href="../tf-graph-info/tf-graph-info.html">
<link rel="import" href="../paper-progress/paper-progress.html">

<!--
Element for putting tf-graph and tf-graph-info side by side.

Example

  <tf-graph-board graph=[[graph]]></tf-graph-board>

-->
<dom-module id="tf-graph-board">
<template>
<style>
::host {
  display: block;
}

/deep/ .close {
  position: absolute;
  cursor: pointer;
  left: 15px;
  bottom: 15px;
}

.container {
  width: 100%;
  height: 100%;
  opacity: 1;
}

.container.loading {
  cursor: progress;
  opacity: 0.1;
}

.container.loading.error {
  cursor: auto;
}

#info {
  position: absolute;
  right: 5px;
  top: 5px;
  padding: 0px;
  max-width: 380px;
  min-width: 320px;
  background-color: rgba(255,255,255,0.9);
  @apply(--shadow-elevation-2dp);
}

#main {
  width: 100%;
  height: 100%;
}

#progress-bar {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  width: 100%;
  position: absolute;
  top: 40px;
  left: 0;
  font-size: 13px;
}

#progress-msg {
  width: 400px;
  margin-bottom: 5px;
}

paper-progress {
  width: 400px;
  --paper-progress-height: 6px;
  --paper-progress-active-color: #f3913e;
}

.context-menu {
  position: absolute;
  display: none;
  background-color: #e2e2e2;
  border-radius: 2px;
  font-size: 14px;
  min-width: 150px;
  border: 1px solid #d4d4d4;
}

/deep/ .context-menu ul {
  list-style-type: none;
  margin: 0;
  padding: 0;
  cursor: default;
}

/deep/ .context-menu ul li {
  padding: 4px 16px;
}

/deep/ .context-menu ul li:hover {
  background-color: #f3913e;
  color: white;
}
</style>
<template is="dom-if" if="[[_isNotComplete(progress)]]">
  <div id="progress-bar">
    <div id="progress-msg">[[progress.msg]]</div>
    <paper-progress value="[[progress.value]]"></paper-progress>
  </div>
</template>
<div class$="[[_getContainerClass(progress)]]">
  <div id="main">
    <tf-graph id="graph"
              graph-hierarchy="{{graphHierarchy}}"
              basic-graph="[[graph]]"
              hierarchy-params="[[hierarchyParams]]"
              render-hierarchy="{{renderHierarchy}}"
              devices-for-stats="[[devicesForStats]]"
              stats="[[stats]]"
              selected-node="{{_selectedNode}}"
              highlighted-node="{{_highlightedNode}}"
              color-by="[[colorBy]]"
              color-by-params="{{colorByParams}}"
              progress="{{progress}}"
              node-names-to-health-pills="[[nodeNamesToHealthPills]]"
              health-pill-step-index="[[healthPillStepIndex]]"
    ></tf-graph>
  </div>
  <div id="info">
    <tf-graph-info id="graph-info"
              title="selected"
              graph-hierarchy="[[graphHierarchy]]"
              render-hierarchy="[[renderHierarchy]]"
              graph="[[graph]]"
              selected-node="{{_selectedNode}}"
              selected-node-include="{{_selectedNodeInclude}}"
              highlighted-node="{{_highlightedNode}}"
              color-by="[[colorBy]]"
              color-by-params="[[colorByParams]]"
              debugger-data-enabled="[[debuggerDataEnabled]]"
              are-health-pills-loading="[[areHealthPillsLoading]]"
              node-names-to-health-pills="[[nodeNamesToHealthPills]]"
              all-steps-mode-enabled="{{allStepsModeEnabled}}"
              specific-health-pill-step="{{specificHealthPillStep}}"
              health-pill-step-index="{{healthPillStepIndex}}"
    ></tf-graph-info>
  </div>
  <div class="context-menu"></div>
</div>
</template>
</dom-module>

<script>
Polymer({
  is: 'tf-graph-board',
  properties: {
    // Public API.
    graphHierarchy: Object,
    graph: Object,
    stats: Object,
    /**
     * @type {value: number, msg: string}
     *
     * A number between 0 and 100 denoting the % of progress
     * for the progress bar and the displayed message.
     */
    progress: Object,
    colorBy: String,
    colorByParams: {
      type: Object,
      notify: true
    },
    renderHierarchy: {
      type: Object,
      notify: true
    },
    // Whether debugger data is enabled for this instance of Tensorboard.
    debuggerDataEnabled: Boolean,
    // Whether health pills are currently being loaded.
    areHealthPillsLoading: Boolean,
    // A mapping between node name to the tf.graph.scene.HealthPill to render.
    nodeNamesToHealthPills: Object,
    // Whether the user can request health pills for individual steps from the server. This can be
    // slow compared the default of showing sampled health pills.
    allStepsModeEnabled: {
      type: Boolean,
      notify: true,
      value: false,
    },
    // Relevant if allStepsModeEnabled. The specific step for which to fetch health pills from the
    // server for.
    specificHealthPillStep: {
      type: Number,
      notify: true,
      value: 0,
    },
    // The step of health pills to show throughout the graph.
    healthPillStepIndex: Number,
    // Private API: Data routing between child components.
    _selectedNode: String,
    // The enum value of the include property of the selected node.
    _selectedNodeInclude: Number,
    _highlightedNode: String
  },
  listeners: {
    'node-toggle-extract': '_nodeToggleExtract'
  },
  observers: [
    '_updateNodeInclude(_selectedNode)'
  ],
  /** True if the progress is not complete yet (< 100 %). */
  _isNotComplete: function(progress) {
    return progress.value < 100;
  },
  _getContainerClass: function(progress) {
    var result = 'container';
    if (progress.error) {
      result += ' error';
    }
    if (this._isNotComplete(progress)) {
      result += ' loading';
    }
    return result;
  },
  _updateNodeInclude: function(nodeName) {
    var node = this.graphHierarchy.node(nodeName);
    this.set("_selectedNodeInclude",
      node ? node.include : tf.graph.InclusionType.UNSPECIFIED);
  },
  _nodeToggleExtract: function() {
    this._updateNodeInclude(this._selectedNode);
  }
});
</script>