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

tf.TensorBuffer.get returns unexpected value #1304

Closed
vabarbosa opened this issue Feb 28, 2019 · 1 comment
Closed

tf.TensorBuffer.get returns unexpected value #1304

vabarbosa opened this issue Feb 28, 2019 · 1 comment
Assignees

Comments

@vabarbosa
Copy link
Contributor

vabarbosa commented Feb 28, 2019

To get help from the community, we encourage using Stack Overflow and the tensorflow.js tag.

TensorFlow.js version

0.15.3

Browser version

Firefox 65.0.1
Chrome 72.0.3626.119

Describe the problem or feature request

i may be wrong in my understanding but my expectation is that TensorBuffer.get should return the value at a given index/location. if an out of bound index/location is provided i would expect it to fail. however, that does not appear to be the case. if you provide a location for a given dimension greater than its size tf.TensorBuffer.get may still return a value.

Code to reproduce the bug / link to feature request

comparing tf.TensorBuffer.get and indexing with tf.Tensor.arraySync:

// [ [ [1, 2], [3, 4] ],
//   [ [5, 6], [7, 8] ] ]
const t = tf.tensor([1, 2, 3, 4, 5, 6, 7, 8], [2, 2, 2])

const b = t.bufferSync()
const a = t.arraySync()

b.get(0, 0, 0) // 1
a[0][0][0]     // 1

b.get(0, 0, 1) // 2
a[0][0][1]     // 2

b.get(0, 0, 2) // 3
a[0][0][2]     // undefined

b.get(0, 2, 0) // 5
a[0][2][0]     // undefined

b.get(2, 0, 0) // undefined
a[2][0][0]     // undefined

b.get(2, 0, 0) correctly returns undefined. however, b.get(0, 0, 2) and b.get(0, 2, 0) incorrectly return a value (for an invalid location).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants