This repository has been archived by the owner on Aug 15, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 955
Add string dtype to Tensor #1408
Merged
Merged
Changes from 22 commits
Commits
Show all changes
31 commits
Select commit
Hold shift + click to select a range
421cd40
save
dsmilkov 8c9258b
save
dsmilkov 5cf1e12
save
dsmilkov 9351969
save
dsmilkov 2f20cf2
Merge remote-tracking branch 'origin' into string-data
dsmilkov b066618
save
dsmilkov 84c1365
save
dsmilkov 21afda0
save
dsmilkov 4769316
save
dsmilkov 054847e
save
dsmilkov 5627d76
save
dsmilkov 3d09b8e
save
dsmilkov 4bcb004
save
dsmilkov 5c6e6dd
save
dsmilkov bb42a88
save
dsmilkov 691ff43
Merge remote-tracking branch 'origin' into string-data
dsmilkov 4a1c3f7
save
dsmilkov b4d3cfb
save
dsmilkov 4ac5327
save
dsmilkov ea13ab2
save
dsmilkov cb02807
save
dsmilkov e2ab930
save
dsmilkov 8977b3c
save
dsmilkov 665232f
save
dsmilkov c971bf9
Merge branch 'string-data' of https://github.com/tensorflow/tfjs-core…
dsmilkov 870db21
save
dsmilkov 81cc45c
save
dsmilkov e950b16
save
dsmilkov 219e4a7
save
dsmilkov a2025e3
merge
dsmilkov 70afeef
save
dsmilkov File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"type": "chrome", | ||
"request": "attach", | ||
"name": "Attach Karma Chrome", | ||
"address": "localhost", | ||
"port": 9333, | ||
"pathMapping": { | ||
"/": "${workspaceRoot}", | ||
"/base/": "${workspaceRoot}/" | ||
} | ||
} | ||
] | ||
} |
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,73 @@ | ||
/** | ||
* @license | ||
* Copyright 2018 Google LLC. 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 * as tf from './index'; | ||
import {describeWithFlags} from './jasmine_util'; | ||
import {ALL_ENVS, expectArraysClose, expectArraysEqual} from './test_util'; | ||
|
||
describeWithFlags('tf.buffer', ALL_ENVS, () => { | ||
it('float32', () => { | ||
const buff = tf.buffer([1, 2, 3], 'float32'); | ||
buff.set(1, 0, 0, 0); | ||
buff.set(2, 0, 1, 0); | ||
expect(buff.get(0, 0, 0)).toEqual(1); | ||
expect(buff.get(0, 0, 1)).toEqual(0); | ||
expect(buff.get(0, 0, 2)).toEqual(0); | ||
expect(buff.get(0, 1, 0)).toEqual(2); | ||
expect(buff.get(0, 1, 1)).toEqual(0); | ||
expect(buff.get(0, 1, 2)).toEqual(0); | ||
expectArraysClose(buff.toTensor(), [1, 0, 0, 2, 0, 0]); | ||
expectArraysClose(buff.values, new Float32Array([1, 0, 0, 2, 0, 0])); | ||
}); | ||
|
||
it('int32', () => { | ||
const buff = tf.buffer([2, 3], 'int32'); | ||
buff.set(1.3, 0, 0); | ||
buff.set(2.1, 1, 1); | ||
expect(buff.get(0, 0)).toEqual(1); | ||
expect(buff.get(0, 1)).toEqual(0); | ||
expect(buff.get(0, 2)).toEqual(0); | ||
expect(buff.get(1, 0)).toEqual(0); | ||
expect(buff.get(1, 1)).toEqual(2); | ||
expect(buff.get(1, 2)).toEqual(0); | ||
expectArraysClose(buff.toTensor(), [1, 0, 0, 0, 2, 0]); | ||
expectArraysClose(buff.values, new Int32Array([1, 0, 0, 0, 2, 0])); | ||
}); | ||
|
||
it('bool', () => { | ||
const buff = tf.buffer([4], 'bool'); | ||
buff.set(true, 1); | ||
buff.set(true, 2); | ||
expect(buff.get(0)).toBeFalsy(); | ||
expect(buff.get(1)).toBeTruthy(); | ||
expect(buff.get(2)).toBeTruthy(); | ||
expect(buff.get(3)).toBeFalsy(); | ||
expectArraysClose(buff.toTensor(), [0, 1, 1, 0]); | ||
expectArraysClose(buff.values, new Uint8Array([0, 1, 1, 0])); | ||
}); | ||
|
||
it('string', () => { | ||
const buff = tf.buffer([2, 2], 'string'); | ||
buff.set('first', 0, 0); | ||
buff.set('third', 1, 0); | ||
expect(buff.get(0, 0)).toEqual('first'); | ||
expect(buff.get(0, 1)).toBeFalsy(); | ||
expect(buff.get(1, 0)).toEqual('third'); | ||
expect(buff.get(1, 1)).toBeFalsy(); | ||
expectArraysEqual(buff.toTensor(), ['first', null, 'third', null]); | ||
}); | ||
}); |
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
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
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.
5 letters? Do we always store string type as UTF-16, do we support UTF-8?