You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jul 15, 2025. It is now read-only.
I am seeing this behavior when creating a Tensor using a buffer that is created by wrapping an array.
The example below can reproduce the issue:
// create an buffer by wrapping an array but buffer start from position 3 and length is 4
final IntBuffer src = IntBuffer.wrap(new int[]{0, 1, 2, 3, 4, 5, 6, 7, 8}, 3, 4).asReadOnlyBuffer();
final org.tensorflow.Tensor tensor = TInt32.tensorOf(Shape.of(4), DataBuffers.of(src));
final int[] value = new int[4];
tensor.asRawTensor().data().asInts().read(value);
assertArrayEquals(new int[]{0, 1, 2, 3}, value); // This is not really a correct behavior, it is not honoring the buffer offset when wrapping the array, it just takes the first 4 elements
//assertArrayEquals(new int[]{3, 4, 5, 6}, value); // This should be the desired result
System info:
Java 8
tensorflow-java (tensorflow-core-api) 0.4.1