diff --git a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ndarray/BaseNDArray.java b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ndarray/BaseNDArray.java index 55ce8039b..835a2f4cb 100644 --- a/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ndarray/BaseNDArray.java +++ b/nd4j/nd4j-backends/nd4j-api-parent/nd4j-api/src/main/java/org/nd4j/linalg/api/ndarray/BaseNDArray.java @@ -5341,7 +5341,7 @@ public abstract class BaseNDArray implements INDArray, Iterable { if (!this.isView()) { Nd4j.getExecutioner().commit(); - DataBuffer buffer = Nd4j.createBuffer(this.length(), false); + DataBuffer buffer = Nd4j.createBuffer(this.dataType(), this.length(), false); Nd4j.getMemoryManager().memcpy(buffer, this.data()); copy = Nd4j.createArrayFromShapeBuffer(buffer, this.shapeInfoDataBuffer()); diff --git a/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/linalg/workspace/SpecialWorkspaceTests.java b/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/linalg/workspace/SpecialWorkspaceTests.java index aefbafe53..2c98d23b1 100644 --- a/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/linalg/workspace/SpecialWorkspaceTests.java +++ b/nd4j/nd4j-backends/nd4j-tests/src/test/java/org/nd4j/linalg/workspace/SpecialWorkspaceTests.java @@ -425,6 +425,21 @@ public class SpecialWorkspaceTests extends BaseNd4jTest { Files.delete(tmpFile); } + + @Test + public void testMigrateToWorkspace(){ + val src = Nd4j.createFromArray (1L,2L); + val wsConf = new WorkspaceConfiguration().builder().build(); + Nd4j.getWorkspaceManager().createNewWorkspace(wsConf,"testWS"); + val ws = Nd4j.getWorkspaceManager().getAndActivateWorkspace("testWS"); + + val migrated = src.migrate(); + assertEquals(src.dataType(), migrated.dataType()); + assertEquals(1L, migrated.getLong(0)); + + ws.close(); + } + @Override public char ordering() { return 'c';