Package org.nd4j.autodiff.samediff.array
Class ThreadSafeArrayHolder
- java.lang.Object
-
- org.nd4j.autodiff.samediff.array.ThreadSafeArrayHolder
-
- All Implemented Interfaces:
ArrayHolder
public class ThreadSafeArrayHolder extends Object implements ArrayHolder
-
-
Constructor Summary
Constructors Constructor Description ThreadSafeArrayHolder(boolean lazyInit)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description Collection<String>
arrayNames()
INDArray
getArray(@NonNull String name)
boolean
hasArray(@NonNull String name)
void
initFrom(ArrayHolder arrayHolder)
Initialize from the specified array holder.INDArray
removeArray(@NonNull String name)
Remove the array from the ArrayHolder, returning it (if it exists)void
rename(@NonNull String from, @NonNull String to)
Rename the entry with the specified namevoid
setArray(@NonNull String name, @NonNull INDArray array)
Set the array for the specified name (new array, or replace if it already exists)int
size()
-
-
-
Constructor Detail
-
ThreadSafeArrayHolder
public ThreadSafeArrayHolder(boolean lazyInit)
- Parameters:
lazyInit
- If true: use lazy initialization forDeviceLocalNDArray
-
-
Method Detail
-
hasArray
public boolean hasArray(@NonNull @NonNull String name)
- Specified by:
hasArray
in interfaceArrayHolder
- Returns:
- True if an array by that name exists
-
getArray
public INDArray getArray(@NonNull @NonNull String name)
- Specified by:
getArray
in interfaceArrayHolder
- Parameters:
name
- Name of the array to get- Returns:
- The array, or null if no array with that name exists
-
setArray
public void setArray(@NonNull @NonNull String name, @NonNull @NonNull INDArray array)
Description copied from interface:ArrayHolder
Set the array for the specified name (new array, or replace if it already exists)- Specified by:
setArray
in interfaceArrayHolder
- Parameters:
name
- Name of the arrayarray
- Array to set
-
removeArray
public INDArray removeArray(@NonNull @NonNull String name)
Description copied from interface:ArrayHolder
Remove the array from the ArrayHolder, returning it (if it exists)- Specified by:
removeArray
in interfaceArrayHolder
- Parameters:
name
- Name of the array to return- Returns:
- The now-removed array
-
size
public int size()
- Specified by:
size
in interfaceArrayHolder
- Returns:
- Number of arrays in the ArrayHolder
-
initFrom
public void initFrom(ArrayHolder arrayHolder)
Description copied from interface:ArrayHolder
Initialize from the specified array holder. This clears all internal arrays, and adds all arrays from the specified array holder- Specified by:
initFrom
in interfaceArrayHolder
- Parameters:
arrayHolder
- Array holder to initialize this based on
-
arrayNames
public Collection<String> arrayNames()
- Specified by:
arrayNames
in interfaceArrayHolder
- Returns:
- Names of the arrays currently in the ArrayHolder
-
rename
public void rename(@NonNull @NonNull String from, @NonNull @NonNull String to)
Description copied from interface:ArrayHolder
Rename the entry with the specified name- Specified by:
rename
in interfaceArrayHolder
- Parameters:
from
- Original nameto
- New name
-
-