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 157b5f8 commit 85cfb76
Showing 1 changed file with 5 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -140,7 +140,7 @@ public static TUint8 buildUByte(RandomAccessibleInterval<UnsignedByteType> tenso
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 );
ByteDataBuffer dataBuffer = RawDataBufferFactory.create(flatArr, false);
TUint8 ndarray = Tensor.of(TUint8.class, Shape.of(ogShape), dataBuffer);
return ndarray;
Expand Down Expand Up @@ -169,7 +169,7 @@ public static TInt32 buildInt(RandomAccessibleInterval<IntType> tensor)
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 );
IntDataBuffer dataBuffer = RawDataBufferFactory.create(flatArr, false);
TInt32 ndarray = TInt32.tensorOf(Shape.of(ogShape),
dataBuffer);
Expand Down Expand Up @@ -199,7 +199,7 @@ private static TInt64 buildLong(RandomAccessibleInterval<LongType> tensor)
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 );
LongDataBuffer dataBuffer = RawDataBufferFactory.create(flatArr, false);
TInt64 ndarray = TInt64.tensorOf(Shape.of(ogShape),
dataBuffer);
Expand Down Expand Up @@ -230,7 +230,7 @@ public static TFloat32 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 );
FloatDataBuffer dataBuffer = RawDataBufferFactory.create(flatArr, false);
TFloat32 ndarray = TFloat32.tensorOf(Shape.of(ogShape), dataBuffer);
return ndarray;
Expand Down Expand Up @@ -260,7 +260,7 @@ private static TFloat64 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 );
DoubleDataBuffer dataBuffer = RawDataBufferFactory.create(flatArr, false);
TFloat64 ndarray = TFloat64.tensorOf(Shape.of(ogShape), dataBuffer);
return ndarray;
Expand Down

0 comments on commit 85cfb76

Please sign in to comment.