Skip to content

Commit

Permalink
come back to c order
Browse files Browse the repository at this point in the history
  • Loading branch information
carlosuc3m committed Oct 18, 2024
1 parent 1fcc519 commit 08d725c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,7 +390,7 @@ private <T extends RealType<T> & NativeType<T>> List<String> encodeInputs(List<T
List<String> encodedInputTensors = new ArrayList<String>();
Gson gson = new Gson();
for (Tensor<?> tt : inputTensors) {
SharedMemoryArray shma = SharedMemoryArray.createSHMAFromRAI(tt.getData(), true, true);
SharedMemoryArray shma = SharedMemoryArray.createSHMAFromRAI(tt.getData(), false, true);
shmaInputList.add(shma);
HashMap<String, Object> map = new HashMap<String, Object>();
map.put(NAME_KEY, tt.getName());
Expand All @@ -415,7 +415,7 @@ List<String> encodeOutputs(List<Tensor<T>> outputTensors) {
if (!tt.isEmpty()) {
map.put(SHAPE_KEY, tt.getShape());
map.put(DTYPE_KEY, CommonUtils.getDataTypeFromRAI(tt.getData()));
SharedMemoryArray shma = SharedMemoryArray.createSHMAFromRAI(tt.getData(), true, true);
SharedMemoryArray shma = SharedMemoryArray.createSHMAFromRAI(tt.getData(), false, true);
shmaOutputList.add(shma);
map.put(MEM_NAME_KEY, shma.getName());
} else if (PlatformDetection.isWindows()){
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ private static void buildFromTensorUByte(NDArray tensor, String memoryName) thro
if (CommonUtils.int32Overflows(arrayShape, 1))
throw new IllegalArgumentException("Model output tensor with shape " + Arrays.toString(arrayShape)
+ " is too big. Max number of elements per ubyte output tensor supported: " + Integer.MAX_VALUE / 1);
SharedMemoryArray shma = SharedMemoryArray.readOrCreate(memoryName, arrayShape, new UnsignedByteType(), true, true);
SharedMemoryArray shma = SharedMemoryArray.readOrCreate(memoryName, arrayShape, new UnsignedByteType(), false, true);
shma.getDataBufferNoHeader().put(tensor.toByteArray());
if (PlatformDetection.isWindows()) shma.close();
}
Expand All @@ -100,7 +100,7 @@ private static void buildFromTensorInt(NDArray tensor, String memoryName) throws
throw new IllegalArgumentException("Model output tensor with shape " + Arrays.toString(arrayShape)
+ " is too big. Max number of elements per int output tensor supported: " + Integer.MAX_VALUE / 4);

SharedMemoryArray shma = SharedMemoryArray.readOrCreate(memoryName, arrayShape, new IntType(), true, true);
SharedMemoryArray shma = SharedMemoryArray.readOrCreate(memoryName, arrayShape, new IntType(), false, true);
shma.getDataBufferNoHeader().put(tensor.toByteArray());
if (PlatformDetection.isWindows()) shma.close();
}
Expand All @@ -112,7 +112,7 @@ private static void buildFromTensorFloat(NDArray tensor, String memoryName) thro
throw new IllegalArgumentException("Model output tensor with shape " + Arrays.toString(arrayShape)
+ " is too big. Max number of elements per float output tensor supported: " + Integer.MAX_VALUE / 4);

SharedMemoryArray shma = SharedMemoryArray.readOrCreate(memoryName, arrayShape, new FloatType(), true, true);
SharedMemoryArray shma = SharedMemoryArray.readOrCreate(memoryName, arrayShape, new FloatType(), false, true);
shma.getDataBufferNoHeader().put(tensor.toByteArray());
if (PlatformDetection.isWindows()) shma.close();
}
Expand All @@ -124,7 +124,7 @@ private static void buildFromTensorDouble(NDArray tensor, String memoryName) thr
throw new IllegalArgumentException("Model output tensor with shape " + Arrays.toString(arrayShape)
+ " is too big. Max number of elements per double output tensor supported: " + Integer.MAX_VALUE / 8);

SharedMemoryArray shma = SharedMemoryArray.readOrCreate(memoryName, arrayShape, new DoubleType(), true, true);
SharedMemoryArray shma = SharedMemoryArray.readOrCreate(memoryName, arrayShape, new DoubleType(), false, true);
shma.getDataBufferNoHeader().put(tensor.toByteArray());
if (PlatformDetection.isWindows()) shma.close();
}
Expand All @@ -137,7 +137,7 @@ private static void buildFromTensorLong(NDArray tensor, String memoryName) throw
+ " is too big. Max number of elements per long output tensor supported: " + Integer.MAX_VALUE / 8);


SharedMemoryArray shma = SharedMemoryArray.readOrCreate(memoryName, arrayShape, new LongType(), true, true);
SharedMemoryArray shma = SharedMemoryArray.readOrCreate(memoryName, arrayShape, new LongType(), false, true);
shma.getDataBufferNoHeader().put(tensor.toByteArray());
if (PlatformDetection.isWindows()) shma.close();
}
Expand Down

0 comments on commit 08d725c

Please sign in to comment.