Skip to content

Commit

Permalink
correct error creating tensors
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Oct 27, 2023
1 parent e1b8bdc commit 4a4a56a
Showing 1 changed file with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ private static Tensor<UInt8> buildByte(
int[] sArr = new int[tensorShape.length];
for (int i = 0; i < sArr.length; i ++)
sArr[i] = (int) tensorShape[i];
blocks.copy( new long[tensorShape.length], flatArr, sArr );
blocks.copy( tensor.minAsLongArray(), flatArr, sArr );
ByteBuffer buff = ByteBuffer.wrap(flatArr);
Tensor<UInt8> ndarray = Tensor.create(UInt8.class, ogShape, buff);
return ndarray;
Expand All @@ -145,7 +145,7 @@ private static Tensor<Integer> buildInt(
int[] sArr = new int[tensorShape.length];
for (int i = 0; i < sArr.length; i ++)
sArr[i] = (int) tensorShape[i];
blocks.copy( new long[tensorShape.length], flatArr, sArr );
blocks.copy( tensor.minAsLongArray(), flatArr, sArr );
IntBuffer buff = IntBuffer.wrap(flatArr);
Tensor<Integer> ndarray = Tensor.create(ogShape, buff);
return ndarray;
Expand All @@ -172,7 +172,7 @@ private static Tensor<Float> buildFloat(
int[] sArr = new int[tensorShape.length];
for (int i = 0; i < sArr.length; i ++)
sArr[i] = (int) tensorShape[i];
blocks.copy( new long[tensorShape.length], flatArr, sArr );
blocks.copy( tensor.minAsLongArray(), flatArr, sArr );
FloatBuffer buff = FloatBuffer.wrap(flatArr);
Tensor<Float> ndarray = Tensor.create(ogShape, buff);
return ndarray;
Expand All @@ -199,7 +199,7 @@ private static Tensor<Double> buildDouble(
int[] sArr = new int[tensorShape.length];
for (int i = 0; i < sArr.length; i ++)
sArr[i] = (int) tensorShape[i];
blocks.copy( new long[tensorShape.length], flatArr, sArr );
blocks.copy( tensor.minAsLongArray(), flatArr, sArr );
DoubleBuffer buff = DoubleBuffer.wrap(flatArr);
Tensor<Double> ndarray = Tensor.create(ogShape, buff);
return ndarray;
Expand Down

0 comments on commit 4a4a56a

Please sign in to comment.