Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix memory viewer due to minor compiler changes. #1280

Merged
merged 2 commits into from
Jul 12, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
<!--
tf-mv-bar shows a small % utilization bar, colored using flameColor.
-->
<dom-module id="tf-nv-bar">
<dom-module id="tf-mv-bar">
<style>
:host {
display: inline-block;
Expand Down Expand Up @@ -74,7 +74,7 @@ <h4>Size: <span>[[size]]</span><b> MiB</b></h4>
<tf-mv-bar value="[[utilization]]"></tf-mv-bar>
</div>
<div hidden="[[!node.shape]]">
<b>Shape: </b>
<b>Shape (and minor-to-major order): </b>
<code class="expression">[[node.shape]]</code>
</div>
<div hidden="[[!node.tfOpName]]">
Expand Down
2 changes: 2 additions & 0 deletions tensorboard/plugins/profile/memory_viewer/utils/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,8 @@ export function byteSizeOfPrimitiveType(type: string): number {
return 8;
case 'C64':
return 8;
case 'TOKEN':
return 0;
default:
console.error('Unhandled primitive type ' + type);
return 0;
Expand Down
25 changes: 14 additions & 11 deletions tensorboard/plugins/profile/memory_viewer/xla/shape.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,17 +48,20 @@ export class Shape {

// We make a simplifying assumption here that the minimum size of a tuple
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this comment stay attached to the other if statement? It looks like that's the one it applies to.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice catch. Thanks!

// member is int64.
if (this.elementType === 'TOKEN') {
return 0;
}
if (this.elementType === 'TUPLE') {
return INT64_BYTES * this.tupleShapes.length;
}
let byteSize = 0;
if (this.layout.format == 'DENSE') {
// We assume the layout format is 'DENSE' by default.
if (!this.layout || this.layout.format == 'DENSE') {
const allocatedElementCount =
this.dimensions.reduce((count, item) => count * item, 1);
byteSize += allocatedElementCount *
memory_viewer.byteSizeOfPrimitiveType(this.elementType);
}
if (this.layout.format == 'SPARSE') {
}else if (this.layout.format == 'SPARSE') {
const maxElements = parseInt(this.layout.maxSparseElements, 10);
byteSize = maxElements * memory_viewer.byteSizeOfPrimitiveType(this.elementType);

Expand All @@ -82,16 +85,16 @@ export class Shape {
}
text += ')';
return text;
} else {
let result = this.elementType.toLowerCase() + '[';
result += this.dimensions.join() + ']';
if (!(this.elementType === 'OPAQUE') && this.dimensions.length > 0) {
if (this.layout) {
result += this.humanLayoutString(this.layout);
}
}
let result = this.elementType.toLowerCase() + '[';
result += this.dimensions.join() + ']';
if (!(this.elementType === 'OPAQUE') && !(this.elementType === 'TOKEN') &&
this.dimensions.length > 0) {
if (this.layout) {
result += this.humanLayoutString(this.layout);
}
return result;
}
return result;
}

/**
Expand Down