diff --git a/src/main/java/io/bioimage/modelrunner/pytorch/javacpp/shm/ShmBuilder.java b/src/main/java/io/bioimage/modelrunner/pytorch/javacpp/shm/ShmBuilder.java index 8df7fdb..13c76d6 100644 --- a/src/main/java/io/bioimage/modelrunner/pytorch/javacpp/shm/ShmBuilder.java +++ b/src/main/java/io/bioimage/modelrunner/pytorch/javacpp/shm/ShmBuilder.java @@ -26,6 +26,7 @@ import java.io.IOException; import java.nio.ByteBuffer; +import java.nio.ByteOrder; import java.nio.DoubleBuffer; import java.nio.FloatBuffer; import java.nio.IntBuffer; @@ -134,7 +135,7 @@ private static void buildFromTensorFloat(Tensor tensor, String memoryName) throw long flatSize = 1; for (long l : arrayShape) {flatSize *= l;} float[] flat = new float[(int) flatSize]; - ByteBuffer byteBuffer = ByteBuffer.allocateDirect((int) (flatSize * Float.BYTES)); + ByteBuffer byteBuffer = ByteBuffer.allocateDirect((int) (flatSize * Float.BYTES)).order(ByteOrder.LITTLE_ENDIAN); FloatBuffer floatBuffer = byteBuffer.asFloatBuffer(); tensor.data_ptr_float().get(flat); floatBuffer.put(flat);