Search in sources :

Example 51 with Nd4jWorkspace

use of org.nd4j.linalg.memory.abstracts.Nd4jWorkspace in project nd4j by deeplearning4j.

the class WorkspaceProviderTests method testNestedWorkspaces8.

@Test
public void testNestedWorkspaces8() throws Exception {
    try (MemoryWorkspace ws = Nd4j.getWorkspaceManager().getAndActivateWorkspace(loopConfiguration, "WS_1")) {
        INDArray array = Nd4j.create(100);
    }
    Nd4jWorkspace workspace = (Nd4jWorkspace) Nd4j.getWorkspaceManager().getWorkspaceForCurrentThread(loopConfiguration, "WS_1");
    workspace.initializeWorkspace();
    assertEquals(100 * Nd4j.sizeOfDataType(), workspace.getCurrentSize());
    try (MemoryWorkspace ws = Nd4j.getWorkspaceManager().getAndActivateWorkspace(loopConfiguration, "WS_1")) {
        INDArray array = Nd4j.create(1000);
    }
    Nd4j.getWorkspaceManager().getWorkspaceForCurrentThread(loopConfiguration, "WS_1").initializeWorkspace();
    assertEquals(100 * Nd4j.sizeOfDataType(), workspace.getCurrentSize());
}
Also used : INDArray(org.nd4j.linalg.api.ndarray.INDArray) MemoryWorkspace(org.nd4j.linalg.api.memory.MemoryWorkspace) Nd4jWorkspace(org.nd4j.linalg.memory.abstracts.Nd4jWorkspace) Test(org.junit.Test) BaseNd4jTest(org.nd4j.linalg.BaseNd4jTest)

Aggregations

Test (org.junit.Test)51 BaseNd4jTest (org.nd4j.linalg.BaseNd4jTest)51 Nd4jWorkspace (org.nd4j.linalg.memory.abstracts.Nd4jWorkspace)51 INDArray (org.nd4j.linalg.api.ndarray.INDArray)47 MemoryWorkspace (org.nd4j.linalg.api.memory.MemoryWorkspace)18 WorkspaceConfiguration (org.nd4j.linalg.api.memory.conf.WorkspaceConfiguration)11 ByteArrayInputStream (java.io.ByteArrayInputStream)2 ByteArrayOutputStream (java.io.ByteArrayOutputStream)2 DataInputStream (java.io.DataInputStream)2 DataOutputStream (java.io.DataOutputStream)2 Ignore (org.junit.Ignore)1 ND4JIllegalStateException (org.nd4j.linalg.exception.ND4JIllegalStateException)1