|
200 | 200 | stroke: var(--tb-graph-faded);
|
201 | 201 | }
|
202 | 202 |
|
| 203 | +#unfilled-rect { |
| 204 | + stroke: #a6a6a6; |
| 205 | +} |
| 206 | + |
| 207 | +.devices-checkbox input { |
| 208 | + text-align: left; |
| 209 | + vertical-align: middle |
| 210 | +} |
| 211 | + |
203 | 212 | .button-text {
|
204 | 213 | text-transform: none;
|
205 | 214 | padding: 8px 18px 0 18px;
|
|
285 | 294 | <use xmlns:xlink="http://www.w3.org/1999/xlink"
|
286 | 295 | xlink:href="#legend-rect"/>
|
287 | 296 | </g>
|
| 297 | + <g id="unfilled-rect"> |
| 298 | + <use xmlns:xlink="http://www.w3.org/1999/xlink" |
| 299 | + xlink:href="#legend-rect"/> |
| 300 | + </g> |
288 | 301 | </defs>
|
289 | 302 | </svg>
|
290 | 303 | <div class="allcontrols">
|
|
412 | 425 | <br style="clear: both">
|
413 | 426 | <div>Devices included in stats:</div>
|
414 | 427 | <div class="deviceList">
|
415 |
| - <table> |
416 |
| - <template is="dom-repeat" items="[[_getDevices(devicesForStats)]]"> |
417 |
| - <tr> |
418 |
| - <td> |
419 |
| - <input type="checkbox" value$="[[item.device]]" checked$="[[item.used]]" on-click="_deviceCheckboxClicked"/> |
420 |
| - </td> |
421 |
| - <td> |
422 |
| - <div> |
423 |
| - <span>[[item.suffix]]</span> |
424 |
| - <template is="dom-if" if="[[item.ignoredMsg]]"> |
425 |
| - <paper-icon-button icon="help" class="help-icon"></paper-icon-button> |
426 |
| - <paper-tooltip position="right" animation-delay="0">[[item.ignoredMsg]]</paper-tooltip> |
427 |
| - </template> |
428 |
| - </div> |
429 |
| - </td> |
430 |
| - </tr> |
| 428 | + <template is="dom-repeat" items="[[_currentDevices]]"> |
| 429 | + <div class="color-legend-row devices-checkbox"> |
| 430 | + <span><input type="checkbox" value$="[[item.device]]" checked$="[[item.used]]" on-click="_deviceCheckboxClicked"/></span> |
| 431 | + <span>[[item.suffix]]</span> |
| 432 | + <template is="dom-if" if="[[item.ignoredMsg]]"> |
| 433 | + <paper-icon-button icon="help" class="help-icon"></paper-icon-button> |
| 434 | + <paper-tooltip position="right" animation-delay="0">[[item.ignoredMsg]]</paper-tooltip> |
| 435 | + </template> |
| 436 | + </div> |
431 | 437 | </template>
|
432 |
| - </table> |
433 | 438 | </div>
|
434 | 439 | </template>
|
435 | 440 | <template is="dom-if" if="[[_equals(colorBy, 'structure')]]">
|
|
450 | 455 | </div>
|
451 | 456 | </template>
|
452 | 457 | <template is="dom-if" if="[[_equals(colorBy, 'device')]]">
|
453 |
| - <div class="color-text"> |
454 |
| - <div class="deviceList"> |
455 |
| - <table> |
456 |
| - <template is="dom-repeat" items="[[colorByParams.device]]"> |
457 |
| - <tr> |
458 |
| - <td style$="[[_getBackgroundColor(item.color)]]"> |
459 |
| - <div class="colorBox"></div> |
460 |
| - </td> |
461 |
| - <td> |
462 |
| - <div>[[item.device]]</div> |
463 |
| - </td> |
464 |
| - </tr> |
465 |
| - </template> |
466 |
| - </table> |
467 |
| - </div> |
468 |
| - <br/> |
| 458 | + <div> |
| 459 | + <template is="dom-repeat" items="[[_currentDeviceParams]]"> |
| 460 | + <div class="color-legend-row"> |
| 461 | + <svg> |
| 462 | + <use xmlns:xlink="http://www.w3.org/1999/xlink" |
| 463 | + xlink:href="#unfilled-rect" x="0" y="0" style="fill:[[item.color]]"/> |
| 464 | + </svg> |
| 465 | + <span class="color-legend-value">[[item.device]]</span> |
| 466 | + </div> |
| 467 | + </template> |
469 | 468 | <div class="color-legend-row">
|
470 | 469 | <svg>
|
471 | 470 | <use xmlns:xlink="http://www.w3.org/1999/xlink"
|
|
479 | 478 | <div class="color-text">
|
480 | 479 | <div class="xlaClusterList">
|
481 | 480 | <table>
|
482 |
| - <template is="dom-repeat" items="[[colorByParams.xla_cluster]]"> |
| 481 | + <template is="dom-repeat" items="[[_currentXlaClusterParams]]"> |
483 | 482 | <tr>
|
484 | 483 | <td style$="[[_getBackgroundColor(item.color)]]">
|
485 | 484 | <div class="colorBox"></div>
|
|
730 | 729 | <script>
|
731 | 730 | (function() { // Private scope.
|
732 | 731 | /**
|
733 |
| - * Stats from device names that match these regexes will be excluded by default. |
734 |
| - * The user can still turn on a device by selecting the checkbox in the device list. |
| 732 | + * Display only devices matching one of the following regex. |
735 | 733 | */
|
736 |
| -var DEVICE_NAMES_EXCLUDE = [ |
| 734 | +var DEVICE_NAMES_INCLUDE = [ |
737 | 735 | {
|
738 |
| - regex: /gpu:[0-9]+$/, |
739 |
| - msg: 'Excluded by default since this is a CPU thread setting up GPU kernels.' |
| 736 | + // Don't include GPU stream, memcpy, etc. devices |
| 737 | + regex: /device:[^:]+:[0-9]+$/, |
740 | 738 | }
|
741 | 739 | ];
|
742 | 740 |
|
| 741 | +/** |
| 742 | + * Stats from device names that match these regexes will be disabled by default. |
| 743 | + * The user can still turn on a device by selecting the checkbox in the device list. |
| 744 | + */ |
| 745 | +var DEVICE_STATS_DEFAULT_OFF = [ |
| 746 | +// { |
| 747 | +// regex: //, |
| 748 | +// msg: 'Excluded by default since...' |
| 749 | +// } |
| 750 | +]; |
| 751 | + |
743 | 752 | Polymer({
|
744 | 753 | is: 'tf-graph-controls',
|
745 | 754 | properties: {
|
|
761 | 770 | notify: true,
|
762 | 771 | readonly: true
|
763 | 772 | },
|
764 |
| - colorByParams: Object, |
| 773 | + colorByParams: { |
| 774 | + type: Object, |
| 775 | + notify: true, |
| 776 | + readonly: true, |
| 777 | + }, |
765 | 778 | datasets: {
|
766 | 779 | type: Array,
|
767 | 780 | observer: '_datasetsChanged'
|
|
789 | 802 | notify: true,
|
790 | 803 | value: -1
|
791 | 804 | },
|
| 805 | + _currentDevices: { |
| 806 | + type: Array, |
| 807 | + computed: '_getCurrentDevices(devicesForStats)' |
| 808 | + }, |
| 809 | + _currentDeviceParams: { |
| 810 | + type: Array, |
| 811 | + computed: '_getCurrentDeviceParams(colorByParams)' |
| 812 | + }, |
| 813 | + _currentXlaClusterParams: { |
| 814 | + type: Array, |
| 815 | + computed: '_getCurrentXlaClusterParams(colorByParams)' |
| 816 | + }, |
792 | 817 | _currentGradientParams: {
|
793 | 818 | type: Object,
|
794 | 819 | computed: '_getCurrentGradientParams(colorByParams, colorBy)'
|
|
833 | 858 | }
|
834 | 859 | var devicesForStats = {};
|
835 | 860 | var devices = _.each(stats.dev_stats, function(d) {
|
836 |
| - // Avoid device names that are ignored by default. |
837 |
| - var exclude = _.some(DEVICE_NAMES_EXCLUDE, function(rule) { |
| 861 | + // Only considered included devices. |
| 862 | + var include = _.some(DEVICE_NAMES_INCLUDE, function(rule) { |
| 863 | + return rule.regex.test(d.device); |
| 864 | + }); |
| 865 | + // Exclude device names that are ignored by default. |
| 866 | + var exclude = _.some(DEVICE_STATS_DEFAULT_OFF, function(rule) { |
838 | 867 | return rule.regex.test(d.device);
|
839 | 868 | });
|
840 |
| - if (!exclude) { |
| 869 | + if (include && !exclude) { |
841 | 870 | devicesForStats[d.device] = true;
|
842 | 871 | }
|
843 | 872 | });
|
844 | 873 | this.set('devicesForStats', devicesForStats);
|
845 | 874 | },
|
846 |
| - _getDevices: function(devicesForStats) { |
847 |
| - var devices = _.map(this.stats.dev_stats, function(d) { |
| 875 | + _getCurrentDevices: function(devicesForStats) { |
| 876 | + var all_devices = _.map(this.stats && this.stats.dev_stats, function(d) { |
848 | 877 | return d.device;
|
849 | 878 | });
|
| 879 | + var devices = _.filter(all_devices, function(d) { |
| 880 | + return _.some(DEVICE_NAMES_INCLUDE, function(rule) { |
| 881 | + return rule.regex.test(d); |
| 882 | + }); |
| 883 | + }); |
850 | 884 | // Devices names can be long so we remove the longest common prefix
|
851 | 885 | // before showing the devices in a list.
|
852 | 886 | var suffixes = tf.graph.util.removeCommonPrefix(devices);
|
| 887 | + if (suffixes.length == 1) { |
| 888 | + var found = suffixes[0].match(/device:([^:]+:[0-9]+)$/); |
| 889 | + if (found) { |
| 890 | + suffixes[0] = found[1]; |
| 891 | + } |
| 892 | + } |
853 | 893 | return _.map(devices, function(device, i) {
|
854 | 894 | var ignoredMsg = null;
|
855 |
| - _.each(DEVICE_NAMES_EXCLUDE, function(rule) { |
| 895 | + _.each(DEVICE_STATS_DEFAULT_OFF, function(rule) { |
856 | 896 | if (rule.regex.test(device)) {
|
857 | 897 | ignoredMsg = rule.msg;
|
858 | 898 | }
|
|
892 | 932 | _equals: function(a, b) {
|
893 | 933 | return a === b;
|
894 | 934 | },
|
| 935 | + _getCurrentDeviceParams: function(colorByParams) { |
| 936 | + var deviceParams = _.filter(colorByParams.device, function(param) { |
| 937 | + return _.some(DEVICE_NAMES_INCLUDE, function(rule) { |
| 938 | + return rule.regex.test(param.device); |
| 939 | + }); |
| 940 | + }); |
| 941 | + // Remove common prefix and merge back corresponding color. If |
| 942 | + // there is only one device then remove everything up to "/device:". |
| 943 | + var suffixes = tf.graph.util.removeCommonPrefix( |
| 944 | + _.map(deviceParams, function(d) { return d.device; })); |
| 945 | + if (suffixes.length == 1) { |
| 946 | + var found = suffixes[0].match(/device:([^:]+:[0-9]+)$/); |
| 947 | + if (found) { |
| 948 | + suffixes[0] = found[1]; |
| 949 | + } |
| 950 | + } |
| 951 | + return _.map(deviceParams, function(d, i) { |
| 952 | + return { device : suffixes[i], color : d.color }; |
| 953 | + }); |
| 954 | + }, |
| 955 | + _getCurrentXlaClusterParams: function(colorByParams) { |
| 956 | + return colorByParams.xla_cluster; |
| 957 | + }, |
895 | 958 | _getCurrentGradientParams: function(colorByParams, colorBy) {
|
896 | 959 | if (!this._isGradientColoring(this.stats, colorBy)) {
|
897 | 960 | return;
|
|
0 commit comments