This repository has been archived by the owner on Sep 17, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 116
Start integration with TensorBoard #197
Merged
Merged
Changes from 27 commits
Commits
Show all changes
32 commits
Select commit
Hold shift + click to select a range
2235585
Working on TensorBoard op support
caisq af891d7
Calling SummaryWriter op and getting DT_RESOURCE output as a string is
caisq 0b56dd0
WIP
caisq 7623739
WIP: createSummaryFileWriter() seems to be creating dirs now
caisq d3ae88e
At a stage where WriteScalarSummary op says int32 != int64 for step
caisq c787a36
Seems to be writing scalar summaries now, though step value seems wrong.
caisq f259290
Checkpoint: TB summary scalar writing basically works
caisq aa0c345
Simplify CopyTFE_TensorHandleDataToResourceArray
caisq ff82823
Gradually removing the int64 hack
caisq 9c986ff
Remove some debugging prints
caisq f725d04
Make int64 full range work; Clean up C++ code; Delete debug code
caisq 4a708df
Fix some comments
caisq d8d10b0
Some clean up
caisq baed1e2
Revise API
caisq 25bf64e
Merge branch 'master' into tensorboard
caisq 093681a
Fix linter errors
caisq 47354ba
Fix linter errors; add comments
caisq da37fd7
Add doc strings
caisq 5bd42cf
Cleanup in summaryWriter()
caisq d785813
Adjust API exports
caisq 3558b26
Change async summaryFileWriter() to sync
caisq 73ad84b
Doc string fix
caisq 2b2ca41
Add code snippet in doc string of `summaryFileWriter()`
caisq 65985a4
Remove obsolete TODO items
caisq c9a00ad
Fix typo; remove unwanted file
caisq e1ae2d9
Fix typo in code snippet
caisq 92ea73c
Address review comments; add guard for int32 value bounds
caisq bf6800c
Add unit tests for int64_tensors.ts
caisq 1045d82
Add unit tests for tensorboard summary methods
caisq 3101217
Respond to review comments
caisq 91e3621
Address review comments
caisq 2e1e058
Merge branch 'master' into tensorboard
caisq File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* @license | ||
* Copyright 2018 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. | ||
* ============================================================================= | ||
*/ | ||
|
||
import {Shape, util} from '@tensorflow/tfjs'; | ||
import {endianness} from 'os'; | ||
|
||
const INT32_MAX = 2147483648; | ||
|
||
/** | ||
* Node.js-specific tensor type: int64-type scalar. | ||
* | ||
* This class is created for a specific purpose: to support | ||
* writing `step`s to TensorBoard via op-kernel bindings. | ||
* `step` is required to have an int64 dtype, but TensorFlow.js | ||
* (tfjs-core) doesn't have a built-in int64 dtype. This is | ||
* related to a lack of `Int64Array` or `Uint64Array` typed | ||
* array in basic JavaScript. | ||
* | ||
* This class is introduced as a workaround. | ||
*/ | ||
export class Int64Scalar { | ||
readonly dtype: string = 'int64'; | ||
readonly rank: number = 1; | ||
private valueArray_: Int32Array; | ||
|
||
private static endiannessOkay_: boolean; | ||
|
||
constructor(readonly value: number) { | ||
if (Int64Scalar.endiannessOkay_ == null) { | ||
if (endianness() !== 'LE') { | ||
throw new Error( | ||
`Int64Scalar does not support endianness of this machine: ` + | ||
`${endianness()}`); | ||
} | ||
Int64Scalar.endiannessOkay_ = true; | ||
} | ||
|
||
util.assert( | ||
value > -INT32_MAX && value < INT32_MAX - 1, | ||
`Got a value outside of the bound of values supported for int64 ` + | ||
`dtype ([-${INT32_MAX}, ${INT32_MAX - 1}]): ${value}`); | ||
util.assert( | ||
Number.isInteger(value), | ||
`Expected value to be an integer, but got ${value}`); | ||
|
||
// We use two int32 elements to represent a int64 value. This assumes | ||
// little endian, which is checked above. | ||
const highPart = Math.floor(value / INT32_MAX); | ||
console.log(`highPart = ${highPart}`); // DEBUG | ||
const lowPart = value % INT32_MAX; | ||
this.valueArray_ = new Int32Array([lowPart, highPart]); | ||
} | ||
|
||
get shape(): Shape { | ||
return []; | ||
} | ||
|
||
/** Get the Int32Array that represents the int64 value. */ | ||
get valueArray(): Int32Array { | ||
return this.valueArray_; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
/** | ||
* @license | ||
* Copyright 2018 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. | ||
* ============================================================================= | ||
*/ | ||
|
||
/** | ||
* Public API symbols under the tf.node.* namespace. | ||
*/ | ||
|
||
import {summaryFileWriter} from './tensorboard'; | ||
|
||
export const node = {summaryFileWriter}; |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm a little confused with this class still.
It represents an
int64
but JS can't handle those types today. It tries to parse the high/low parts of the number and validate endianness? This is mostly confusing because I think we just wanted to check that the numbers are withinINT32_MIN
andINT32_MAX
. Why do we need all the various other stuff - seems somewhat expensive for not doing anything.