T
- Enumeration type to specify the type of array. For example, in DL4J the type values include things
like inputs, activations, working memory etc.public interface WorkspaceMgr<T extends Enum<T>>
Modifier and Type | Method and Description |
---|---|
void |
assertCurrentWorkspace(T arrayType,
String msg)
Assert that the current workspace is the one for the specified array type.
|
void |
assertNotOpen(T arrayType,
String msg)
Assert thath the workspace for the specified array type is not open.
|
void |
assertOpen(T arrayType,
String msg)
Assert thath the workspace for the specified array type is open.
|
INDArray |
castTo(T arrayType,
@NonNull DataType dataType,
@NonNull INDArray toCast,
boolean dupIfCorrectType)
Cast the specified array to the specified datatype.
If the array is already the correct type, the bahaviour depends on the 'dupIfCorrectType' argument. dupIfCorrectType = false && toCast.dataType() == dataType: return input array as-is (unless workspace is wrong) dupIfCorrectType = true && toCast.dataType() == dataType: duplicate the array into the specified workspace |
INDArray |
create(T arrayType,
DataType dataType,
long... shape)
Create an array in the specified array type's workspace (or detached if none is specified).
|
INDArray |
create(T arrayType,
DataType dataType,
long[] shape,
char ordering)
Create an array in the specified array type's workspace (or detached if none is specified).
|
INDArray |
createUninitialized(T arrayType,
DataType dataType,
long... shape)
Create an uninitialized array in the specified array type's workspace (or detached if none is specified).
|
INDArray |
createUninitialized(T arrayType,
DataType dataType,
long[] shape,
char order)
Create an uninitialized array in the specified array type's workspace (or detached if none is specified).
|
INDArray |
dup(T arrayType,
@NonNull INDArray toDup)
Duplicate the array, where the array is put into the specified array type's workspace (if applicable)
|
INDArray |
dup(T arrayType,
INDArray toDup,
char order)
Duplicate the array, where the array is put into the specified array type's workspace (if applicable)
|
WorkspaceConfiguration |
getConfiguration(T arrayType) |
String |
getWorkspaceName(T arrayType) |
boolean |
hasConfiguration(T arrayType)
Has the specified array type been configured in this workspace manager?
|
boolean |
isScopedOut(T arrayType) |
boolean |
isWorkspaceOpen(T arrayType)
Check if the workspace for the specified array type is open.
|
INDArray |
leverageTo(T toWorkspace,
INDArray array)
Leverage the array to the specified array type's workspace (or detach if required).
|
MemoryWorkspace |
notifyScopeBorrowed(T arrayType)
Borrow the scope for the specified array type
|
WorkspacesCloseable |
notifyScopeEntered(T... arrayTypes)
Open/enter multiple workspaces.
|
MemoryWorkspace |
notifyScopeEntered(T arrayType) |
void |
setConfiguration(T arrayType,
WorkspaceConfiguration configuration)
Set the workspace configuration for the specified array type
|
void |
setScopedOutFor(T arrayType)
Set arrays to be scoped out (not in any workspace) for the specified array type.
|
void |
setWorkspace(T arrayType,
String wsName,
WorkspaceConfiguration configuration)
Seth the workspace name and configuration for the specified array type
|
void |
setWorkspaceName(T arrayType,
String wsName)
Set the workspace name for the specified array type
|
INDArray |
validateArrayLocation(T arrayType,
INDArray array,
boolean migrateIfInvalid,
boolean exceptionIfDetached)
Validate that the specified array type is actually in the workspace it's supposed to be in
|
void setWorkspaceName(T arrayType, String wsName)
arrayType
- Array type to set the workspace name forwsName
- Workspace name to setString getWorkspaceName(T arrayType)
arrayType
- Array type to get the workspace name for (if set)void setWorkspace(T arrayType, String wsName, WorkspaceConfiguration configuration)
arrayType
- Array typewsName
- Workspace nameconfiguration
- Workspace configurationvoid setConfiguration(T arrayType, WorkspaceConfiguration configuration)
arrayType
- Type of array to set the configuration forconfiguration
- Configuration for the specified array typeWorkspaceConfiguration getConfiguration(T arrayType)
arrayType
- Array type to get the workspace configuration forvoid setScopedOutFor(T arrayType)
arrayType
- Array type to set scoped out forboolean isScopedOut(T arrayType)
arrayType
- Array typeboolean hasConfiguration(T arrayType)
arrayType
- Array type to checkMemoryWorkspace notifyScopeEntered(T arrayType)
arrayType
- Array type to enter the scope forWorkspacesCloseable notifyScopeEntered(T... arrayTypes)
arrayTypes
- Open the specified workspacesMemoryWorkspace notifyScopeBorrowed(T arrayType)
arrayType
- Array type to borrow the scope forboolean isWorkspaceOpen(T arrayType)
arrayType
- Array typevoid assertOpen(T arrayType, String msg) throws ND4JWorkspaceException
arrayType
- Array type to checkmsg
- May be null. If non-null: include this in the exceptionND4JWorkspaceException
- If the specified workspace is not openvoid assertNotOpen(T arrayType, String msg) throws ND4JWorkspaceException
arrayType
- Array type to checkmsg
- May be null. If non-null: include this in the exceptionND4JWorkspaceException
- If the specified workspace is openvoid assertCurrentWorkspace(T arrayType, String msg) throws ND4JWorkspaceException
isWorkspaceOpen(Enum)
scoped out array types are ignored here.arrayType
- Array type to checkmsg
- May be null. Message to include in the exceptionND4JWorkspaceException
INDArray leverageTo(T toWorkspace, INDArray array)
toWorkspace
- Array type's workspace to move the array toarray
- Array to leverageINDArray validateArrayLocation(T arrayType, INDArray array, boolean migrateIfInvalid, boolean exceptionIfDetached) throws ND4JWorkspaceException
arrayType
- Array type of the arrayarray
- Array to checkmigrateIfInvalid
- if true, and array is in the wrong WS: migrate the array and return. If false and in
the wrong WS: exceptionexceptionIfDetached
- If true: if the workspace is detached, but is expected to be in a workspace: should an
exception be thrown?ND4JWorkspaceException
- If the array is in the incorrect workspace (and migrateIfInvalid == false)INDArray create(T arrayType, DataType dataType, long... shape)
Nd4j.create(int...)
, other than the array locationarrayType
- Array typedataType
- Data type for the created arrayshape
- ShapeINDArray create(T arrayType, DataType dataType, long[] shape, char ordering)
Nd4j.create(int[],char)
, other than the array locationarrayType
- Array typedataType
- Data type for the created arrayshape
- Shapeordering
- Order of the arrayINDArray createUninitialized(T arrayType, DataType dataType, long... shape)
org.nd4j.linalg.factory.Nd4j#createUninitialized(int)
(int...)}, other than the array locationarrayType
- Array typedataType
- Data type of the created arrayshape
- ShapeINDArray createUninitialized(T arrayType, DataType dataType, long[] shape, char order)
Nd4j.createUninitialized(int[], char)
}, other than the array locationarrayType
- Array typedataType
- Data type of the returned arrayshape
- Shapeorder
- Order of the arrayINDArray dup(@NonNull T arrayType, @NonNull @NonNull INDArray toDup)
arrayType
- Array type for the resulttoDup
- Array to duplicateINDArray dup(T arrayType, INDArray toDup, char order)
arrayType
- Array type for the resulttoDup
- Array to duplicateorder
- Order for the duplicated arrayINDArray castTo(@NonNull T arrayType, @NonNull @NonNull DataType dataType, @NonNull @NonNull INDArray toCast, boolean dupIfCorrectType)
arrayType
- Array typedataType
- Data typetoCast
- Array to castdupIfCorrectType
- False: return array as-is if correct type and in the correct workspace. True: dup if already correct typeCopyright © 2020. All rights reserved.