Package org.nd4j.linalg.api.memory
Interface MemoryWorkspace
-
- All Superinterfaces:
AutoCloseable,Deallocatable
- All Known Implementing Classes:
DummyWorkspace,Nd4jWorkspace
public interface MemoryWorkspace extends AutoCloseable, Deallocatable
-
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classMemoryWorkspace.Type
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_ID
-
Method Summary
All Methods Instance Methods Abstract 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.voiddestroyWorkspace()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 current cycle, in bytesLonggetThreadId()This method returns threadId where this workspace was createdWorkspaceConfigurationgetWorkspaceConfiguration()This method returns WorkspaceConfiguration bean that was used for given Workspace instanceMemoryWorkspace.TypegetWorkspaceType()This method returns Type of this workspacevoidinitializeWorkspace()This method causes Workspace initialization PLEASE NOTE: This call will have no effect on previously initialized WorkspacebooleanisScopeActive()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 workspacevoidtoggleWorkspaceUse(boolean isEnabled)This method allows you to temporary disable/enable given Workspace use.-
Methods inherited from interface org.nd4j.linalg.api.memory.Deallocatable
deallocator, getUniqueId, targetDevice
-
-
-
-
Field Detail
-
DEFAULT_ID
static final String DEFAULT_ID
- See Also:
- Constant Field Values
-
-
Method Detail
-
getWorkspaceConfiguration
WorkspaceConfiguration getWorkspaceConfiguration()
This method returns WorkspaceConfiguration bean that was used for given Workspace instance- Returns:
-
getWorkspaceType
MemoryWorkspace.Type getWorkspaceType()
This method returns Type of this workspace- Returns:
-
getId
String getId()
This method returns Id of this workspace- Returns:
-
getDeviceId
int getDeviceId()
Returns deviceId for this workspace- Returns:
-
getThreadId
Long getThreadId()
This method returns threadId where this workspace was created- Returns:
-
getGenerationId
long getGenerationId()
This method returns current generation Id- Returns:
-
alloc
PagedPointer alloc(long requiredMemory, DataType dataType, boolean initialize)
This method does allocation from a given Workspace- Parameters:
requiredMemory- allocation size, in bytesdataType- dataType that is going to be used- Returns:
-
getPrimaryOffset
long getPrimaryOffset()
-
alloc
PagedPointer alloc(long requiredMemory, MemoryKind kind, DataType dataType, boolean initialize)
This method does allocation from a given Workspace- Parameters:
requiredMemory- allocation size, in byteskind- MemoryKind for allocationdataType- dataType that is going to be used- Returns:
-
notifyScopeEntered
MemoryWorkspace notifyScopeEntered()
This method notifies given Workspace that new use cycle is starting now- Returns:
-
notifyScopeBorrowed
MemoryWorkspace notifyScopeBorrowed()
This method TEMPORARY enters this workspace, without reset applied- Returns:
-
notifyScopeLeft
MemoryWorkspace notifyScopeLeft()
This method notifies given Workspace that use cycle just ended- Returns:
-
isScopeActive
boolean isScopeActive()
This method returns True if scope was opened, and not closed yet.- Returns:
-
initializeWorkspace
void initializeWorkspace()
This method causes Workspace initialization PLEASE NOTE: This call will have no effect on previously initialized Workspace
-
destroyWorkspace
void destroyWorkspace()
This method causes Workspace destruction: all memory allocations are released after this call.
-
destroyWorkspace
void destroyWorkspace(boolean extended)
-
toggleWorkspaceUse
void toggleWorkspaceUse(boolean isEnabled)
This method allows you to temporary disable/enable given Workspace use. If turned off - direct memory allocations will be used.- Parameters:
isEnabled-
-
getThisCycleAllocations
long getThisCycleAllocations()
This method returns amount of memory consumed in current cycle, in bytes- Returns:
-
enableDebug
void enableDebug(boolean reallyEnable)
This method enabled debugging mode for this workspace- Parameters:
reallyEnable-
-
getLastCycleAllocations
long getLastCycleAllocations()
This method returns amount of memory consumed in last successful cycle, in bytes- Returns:
-
getMaxCycleAllocations
long getMaxCycleAllocations()
This method returns amount of memory consumed by largest successful cycle, in bytes- Returns:
-
getCurrentSize
long getCurrentSize()
This methos returns current allocated size of this workspace- Returns:
-
close
void close()
This method is for compatibility with "try-with-resources" java blocks. Internally it should be equal to notifyScopeLeft() method- Specified by:
closein interfaceAutoCloseable
-
getParentWorkspace
MemoryWorkspace getParentWorkspace()
This method returns parent Workspace, if any. Null if there's none.- Returns:
-
tagOutOfScopeUse
MemoryWorkspace tagOutOfScopeUse()
This method temporary disables this workspace- Returns:
-
setPreviousWorkspace
void setPreviousWorkspace(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. Incorrect use of this method may leave workspace management in an invalid/indeterminant state!- Parameters:
memoryWorkspace- Workspace to set as the previous workspace. This is the workspace that will become active when this workspace is closed.
-
getCurrentOffset
long getCurrentOffset()
This mehtod returns current offset within buffer- Returns:
-
-