Class ParamservUtils
- java.lang.Object
-
- org.apache.sysds.runtime.controlprogram.paramserv.ParamservUtils
-
public class ParamservUtils extends Object
-
-
Field Summary
Fields Modifier and Type Field Description static String
PS_FUNC_PREFIX
static long
SEED
-
Constructor Summary
Constructors Constructor Description ParamservUtils()
-
Method Summary
All Methods Static Methods Concrete Methods Modifier and Type Method Description static ListObject
accrueGradients(ListObject accGradients, ListObject gradients, boolean cleanup)
Accumulate the given gradients into the accrued gradientsstatic ListObject
accrueGradients(ListObject accGradients, ListObject gradients, boolean par, boolean cleanup)
Accumulate the given gradients into the accrued gradientsstatic ListObject
accrueModels(ListObject accModels, ListObject model, boolean cleanup)
Accumulate the given models into the accrued accrueModelsstatic ListObject
accrueModels(ListObject accModels, ListObject model, boolean par, boolean cleanup)
Accumulate the given models into the accrued modelsstatic MatrixBlock
cbindMatrix(MatrixBlock left, MatrixBlock right)
static void
cleanupData(ExecutionContext ec, String varName)
static void
cleanupData(ExecutionContext ec, Data data)
static void
cleanupListObject(ExecutionContext ec, String lName)
Clean up the list object according to its own data statusstatic void
cleanupListObject(ExecutionContext ec, String lName, boolean[] status)
Clean up the list object according to the given array of data status (i.e., false => not be removed)static void
cleanupListObject(ExecutionContext ec, ListObject lo)
static void
cleanupListObject(ExecutionContext ec, ListObject lo, boolean[] status)
static void
cleanupListObject(ListObject lo)
static List<ExecutionContext>
copyExecutionContext(ExecutionContext ec, int num)
static ListObject
copyList(ListObject lo, boolean cleanup)
Deep copy the list objectstatic ExecutionContext
createExecutionContext(ExecutionContext ec, LocalVariableMap varsMap, String updFunc, String aggFunc, int k)
static ExecutionContext
createExecutionContext(ExecutionContext ec, LocalVariableMap varsMap, String updFunc, String aggFunc, int k, boolean forceExecTypeCP)
static MatrixObject
createShallowCopy(MatrixObject mo)
static MatrixBlock
generatePermutation(int numEntries, long seed)
Generate the permutationstatic MatrixBlock
generateReplicationMatrix(int nsamples, int nrows, long seed)
Generates a matrix which when left multiplied with the input matrix will replicate n data rowsstatic MatrixBlock
generateSubsampleMatrix(int nsamples, int nrows, long seed)
Generates a matrix which when left multiplied with the input matrix will subsamplestatic MatrixObject
newMatrixObject(MatrixBlock mb)
static MatrixObject
newMatrixObject(MatrixBlock mb, boolean cleanup)
static void
recompileProgramBlocks(int k, List<ProgramBlock> pbs)
static void
recompileProgramBlocks(int k, List<ProgramBlock> pbs, boolean forceExecTypeCP)
static MatrixObject
sliceMatrix(MatrixObject mo, long rl, long rh)
Slice the matrixstatic MatrixBlock
sliceMatrixBlock(MatrixBlock mb, long rl, long rh)
Slice the matrix block and return a matrix block (used in spark)
-
-
-
Field Detail
-
PS_FUNC_PREFIX
public static final String PS_FUNC_PREFIX
- See Also:
- Constant Field Values
-
SEED
public static long SEED
-
-
Method Detail
-
copyList
public static ListObject copyList(ListObject lo, boolean cleanup)
Deep copy the list object- Parameters:
lo
- list objectcleanup
- clean up the given list object- Returns:
- a new copied list object
-
cleanupListObject
public static void cleanupListObject(ExecutionContext ec, String lName)
Clean up the list object according to its own data status- Parameters:
ec
- execution contextlName
- list var name
-
cleanupListObject
public static void cleanupListObject(ExecutionContext ec, String lName, boolean[] status)
Clean up the list object according to the given array of data status (i.e., false => not be removed)- Parameters:
ec
- execution contextlName
- list var namestatus
- data status
-
cleanupListObject
public static void cleanupListObject(ExecutionContext ec, ListObject lo)
-
cleanupListObject
public static void cleanupListObject(ExecutionContext ec, ListObject lo, boolean[] status)
-
cleanupData
public static void cleanupData(ExecutionContext ec, Data data)
-
cleanupData
public static void cleanupData(ExecutionContext ec, String varName)
-
cleanupListObject
public static void cleanupListObject(ListObject lo)
-
newMatrixObject
public static MatrixObject newMatrixObject(MatrixBlock mb)
-
newMatrixObject
public static MatrixObject newMatrixObject(MatrixBlock mb, boolean cleanup)
-
createShallowCopy
public static MatrixObject createShallowCopy(MatrixObject mo)
-
sliceMatrix
public static MatrixObject sliceMatrix(MatrixObject mo, long rl, long rh)
Slice the matrix- Parameters:
mo
- input matrixrl
- low boundaryrh
- high boundary- Returns:
- new sliced matrix
-
sliceMatrixBlock
public static MatrixBlock sliceMatrixBlock(MatrixBlock mb, long rl, long rh)
Slice the matrix block and return a matrix block (used in spark)- Parameters:
mb
- input matrixrl
- low boundaryrh
- high boundary- Returns:
- new sliced matrix block
-
generatePermutation
public static MatrixBlock generatePermutation(int numEntries, long seed)
Generate the permutation- Parameters:
numEntries
- permutation sizeseed
- seed used to generate random number- Returns:
- permutation matrix
-
generateSubsampleMatrix
public static MatrixBlock generateSubsampleMatrix(int nsamples, int nrows, long seed)
Generates a matrix which when left multiplied with the input matrix will subsample- Parameters:
nsamples
- number of samplesnrows
- number of rows in input matrixseed
- seed used to generate random number- Returns:
- subsample matrix
-
generateReplicationMatrix
public static MatrixBlock generateReplicationMatrix(int nsamples, int nrows, long seed)
Generates a matrix which when left multiplied with the input matrix will replicate n data rows- Parameters:
nsamples
- number of samplesnrows
- number of rows in input matrixseed
- seed used to generate random number- Returns:
- replication matrix
-
createExecutionContext
public static ExecutionContext createExecutionContext(ExecutionContext ec, LocalVariableMap varsMap, String updFunc, String aggFunc, int k)
-
createExecutionContext
public static ExecutionContext createExecutionContext(ExecutionContext ec, LocalVariableMap varsMap, String updFunc, String aggFunc, int k, boolean forceExecTypeCP)
-
copyExecutionContext
public static List<ExecutionContext> copyExecutionContext(ExecutionContext ec, int num)
-
recompileProgramBlocks
public static void recompileProgramBlocks(int k, List<ProgramBlock> pbs)
-
recompileProgramBlocks
public static void recompileProgramBlocks(int k, List<ProgramBlock> pbs, boolean forceExecTypeCP)
-
cbindMatrix
public static MatrixBlock cbindMatrix(MatrixBlock left, MatrixBlock right)
-
accrueGradients
public static ListObject accrueGradients(ListObject accGradients, ListObject gradients, boolean cleanup)
Accumulate the given gradients into the accrued gradients- Parameters:
accGradients
- accrued gradients list objectgradients
- given gradients list objectcleanup
- clean up the given gradients list object- Returns:
- new accrued gradients list object
-
accrueGradients
public static ListObject accrueGradients(ListObject accGradients, ListObject gradients, boolean par, boolean cleanup)
Accumulate the given gradients into the accrued gradients- Parameters:
accGradients
- accrued gradients list objectgradients
- given gradients list objectpar
- parallel executioncleanup
- clean up the given gradients list object- Returns:
- new accrued gradients list object
-
accrueModels
public static ListObject accrueModels(ListObject accModels, ListObject model, boolean cleanup)
Accumulate the given models into the accrued accrueModels- Parameters:
accModels
- accrued models list objectmodel
- given models list objectcleanup
- clean up the given models list object- Returns:
- new accrued models list object
-
accrueModels
public static ListObject accrueModels(ListObject accModels, ListObject model, boolean par, boolean cleanup)
Accumulate the given models into the accrued models- Parameters:
accModels
- accrued models list objectmodel
- given models list objectpar
- parallel executioncleanup
- clean up the given models list object- Returns:
- new accrued models list object
-
-