Class DummyWorkspace
- java.lang.Object
-
- org.nd4j.linalg.api.memory.abstracts.DummyWorkspace
-
- All Implemented Interfaces:
AutoCloseable,Deallocatable,MemoryWorkspace
public class DummyWorkspace extends Object implements MemoryWorkspace
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.nd4j.linalg.api.memory.MemoryWorkspace
MemoryWorkspace.Type
-
-
Field Summary
Fields Modifier and Type Field Description protected MemoryWorkspaceparentWorkspace-
Fields inherited from interface org.nd4j.linalg.api.memory.MemoryWorkspace
DEFAULT_ID
-
-
Constructor Summary
Constructors Constructor Description DummyWorkspace()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description PagedPointeralloc(long requiredMemory, DataType dataType, boolean initialize)This method does allocation from a given WorkspacePagedPointeralloc(long requiredMemory, MemoryKind kind, DataType dataType, boolean initialize)This method does allocation from a given Workspacevoidclose()This method is for compatibility with "try-with-resources" java blocks.Deallocatordeallocator()This method returns deallocator associated with this instancevoiddestroyWorkspace()This method causes Workspace destruction: all memory allocations are released after this call.voiddestroyWorkspace(boolean extended)voidenableDebug(boolean reallyEnable)This method enabled debugging mode for this workspacelonggetCurrentOffset()This mehtod returns current offset within bufferlonggetCurrentSize()This methos returns current allocated size of this workspaceintgetDeviceId()Returns deviceId for this workspacelonggetGenerationId()This method returns current generation IdStringgetId()This method returns Id of this workspacelonggetLastCycleAllocations()This method returns amount of memory consumed in last successful cycle, in byteslonggetMaxCycleAllocations()This method returns amount of memory consumed by largest successful cycle, in bytesMemoryWorkspacegetParentWorkspace()This method returns parent Workspace, if any.longgetPrimaryOffset()longgetThisCycleAllocations()This method returns amount of memory consumed in last successful cycle, in bytesLonggetThreadId()This method returns threadId where this workspace was createdStringgetUniqueId()This method returns unique ID for this instanceWorkspaceConfigurationgetWorkspaceConfiguration()This method returns WorkspaceConfiguration bean that was used for given Workspace instanceMemoryWorkspace.TypegetWorkspaceType()This method returns Type of this workspacevoidinitializeWorkspace()This method causes Workspace initializationbooleanisScopeActive()This method returns True if scope was opened, and not closed yet.MemoryWorkspacenotifyScopeBorrowed()This method TEMPORARY enters this workspace, without reset appliedMemoryWorkspacenotifyScopeEntered()This method notifies given Workspace that new use cycle is starting nowMemoryWorkspacenotifyScopeLeft()This method notifies given Workspace that use cycle just endedvoidsetPreviousWorkspace(MemoryWorkspace memoryWorkspace)Set the previous workspace, if any
NOTE: this method should only be used if you are fully aware of the consequences of doing so.MemoryWorkspacetagOutOfScopeUse()This method temporary disables this workspaceinttargetDevice()This method returns deviceId it's affined with, so deallocator thread will be guaranteed to match itvoidtoggleWorkspaceUse(boolean isEnabled)This method allows you to temporary disable/enable given Workspace use.
-
-
-
Field Detail
-
parentWorkspace
protected MemoryWorkspace parentWorkspace
-
-
Method Detail
-
getWorkspaceConfiguration
public WorkspaceConfiguration getWorkspaceConfiguration()
This method returns WorkspaceConfiguration bean that was used for given Workspace instance- Specified by:
getWorkspaceConfigurationin interfaceMemoryWorkspace- Returns:
-
getId
public String getId()
This method returns Id of this workspace- Specified by:
getIdin interfaceMemoryWorkspace- Returns:
-
getThreadId
public Long getThreadId()
Description copied from interface:MemoryWorkspaceThis method returns threadId where this workspace was created- Specified by:
getThreadIdin interfaceMemoryWorkspace- Returns:
-
getDeviceId
public int getDeviceId()
Description copied from interface:MemoryWorkspaceReturns deviceId for this workspace- Specified by:
getDeviceIdin interfaceMemoryWorkspace- Returns:
-
getWorkspaceType
public MemoryWorkspace.Type getWorkspaceType()
Description copied from interface:MemoryWorkspaceThis method returns Type of this workspace- Specified by:
getWorkspaceTypein interfaceMemoryWorkspace- Returns:
-
alloc
public PagedPointer alloc(long requiredMemory, DataType dataType, boolean initialize)
This method does allocation from a given Workspace- Specified by:
allocin interfaceMemoryWorkspace- Parameters:
requiredMemory- allocation size, in bytesdataType- dataType that is going to be usedinitialize-- Returns:
-
alloc
public PagedPointer alloc(long requiredMemory, MemoryKind kind, DataType dataType, boolean initialize)
This method does allocation from a given Workspace- Specified by:
allocin interfaceMemoryWorkspace- Parameters:
requiredMemory- allocation size, in byteskind- MemoryKind for allocationdataType- dataType that is going to be usedinitialize-- Returns:
-
getGenerationId
public long getGenerationId()
Description copied from interface:MemoryWorkspaceThis method returns current generation Id- Specified by:
getGenerationIdin interfaceMemoryWorkspace- Returns:
-
notifyScopeEntered
public MemoryWorkspace notifyScopeEntered()
This method notifies given Workspace that new use cycle is starting now- Specified by:
notifyScopeEnteredin interfaceMemoryWorkspace- Returns:
-
notifyScopeBorrowed
public MemoryWorkspace notifyScopeBorrowed()
This method TEMPORARY enters this workspace, without reset applied- Specified by:
notifyScopeBorrowedin interfaceMemoryWorkspace- Returns:
-
notifyScopeLeft
public MemoryWorkspace notifyScopeLeft()
This method notifies given Workspace that use cycle just ended- Specified by:
notifyScopeLeftin interfaceMemoryWorkspace- Returns:
-
isScopeActive
public boolean isScopeActive()
This method returns True if scope was opened, and not closed yet.- Specified by:
isScopeActivein interfaceMemoryWorkspace- Returns:
-
initializeWorkspace
public void initializeWorkspace()
This method causes Workspace initializationPLEASE NOTE: This call will have no effect on previously initialized Workspace
- Specified by:
initializeWorkspacein interfaceMemoryWorkspace
-
destroyWorkspace
public void destroyWorkspace()
This method causes Workspace destruction: all memory allocations are released after this call.- Specified by:
destroyWorkspacein interfaceMemoryWorkspace
-
destroyWorkspace
public void destroyWorkspace(boolean extended)
- Specified by:
destroyWorkspacein interfaceMemoryWorkspace
-
toggleWorkspaceUse
public void toggleWorkspaceUse(boolean isEnabled)
This method allows you to temporary disable/enable given Workspace use. If turned off - direct memory allocations will be used.- Specified by:
toggleWorkspaceUsein interfaceMemoryWorkspace- Parameters:
isEnabled-
-
getThisCycleAllocations
public long getThisCycleAllocations()
This method returns amount of memory consumed in last successful cycle, in bytes- Specified by:
getThisCycleAllocationsin interfaceMemoryWorkspace- Returns:
-
enableDebug
public void enableDebug(boolean reallyEnable)
This method enabled debugging mode for this workspace- Specified by:
enableDebugin interfaceMemoryWorkspace- Parameters:
reallyEnable-
-
getLastCycleAllocations
public long getLastCycleAllocations()
This method returns amount of memory consumed in last successful cycle, in bytes- Specified by:
getLastCycleAllocationsin interfaceMemoryWorkspace- Returns:
-
getMaxCycleAllocations
public long getMaxCycleAllocations()
This method returns amount of memory consumed by largest successful cycle, in bytes- Specified by:
getMaxCycleAllocationsin interfaceMemoryWorkspace- Returns:
-
getCurrentSize
public long getCurrentSize()
This methos returns current allocated size of this workspace- Specified by:
getCurrentSizein interfaceMemoryWorkspace- Returns:
-
close
public void close()
Description copied from interface:MemoryWorkspaceThis method is for compatibility with "try-with-resources" java blocks. Internally it should be equal to notifyScopeLeft() method- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceMemoryWorkspace
-
getParentWorkspace
public MemoryWorkspace getParentWorkspace()
This method returns parent Workspace, if any. Null if there's none.- Specified by:
getParentWorkspacein interfaceMemoryWorkspace- Returns:
-
tagOutOfScopeUse
public MemoryWorkspace tagOutOfScopeUse()
Description copied from interface:MemoryWorkspaceThis method temporary disables this workspace- Specified by:
tagOutOfScopeUsein interfaceMemoryWorkspace- Returns:
-
setPreviousWorkspace
public void setPreviousWorkspace(MemoryWorkspace memoryWorkspace)
Description copied from interface:MemoryWorkspaceSet the previous workspace, if any
NOTE: this method should only be used if you are fully aware of the consequences of doing so. Incorrect use of this method may leave workspace management in an invalid/indeterminant state!- Specified by:
setPreviousWorkspacein interfaceMemoryWorkspace- Parameters:
memoryWorkspace- Workspace to set as the previous workspace. This is the workspace that will become active when this workspace is closed.
-
getCurrentOffset
public long getCurrentOffset()
Description copied from interface:MemoryWorkspaceThis mehtod returns current offset within buffer- Specified by:
getCurrentOffsetin interfaceMemoryWorkspace- Returns:
-
getUniqueId
public String getUniqueId()
Description copied from interface:DeallocatableThis method returns unique ID for this instance- Specified by:
getUniqueIdin interfaceDeallocatable- Returns:
-
deallocator
public Deallocator deallocator()
Description copied from interface:DeallocatableThis method returns deallocator associated with this instance- Specified by:
deallocatorin interfaceDeallocatable- Returns:
-
targetDevice
public int targetDevice()
Description copied from interface:DeallocatableThis method returns deviceId it's affined with, so deallocator thread will be guaranteed to match it- Specified by:
targetDevicein interfaceDeallocatable
-
getPrimaryOffset
public long getPrimaryOffset()
- Specified by:
getPrimaryOffsetin interfaceMemoryWorkspace
-
-