use of com.tencent.angel.ml.matrix.psf.get.enhance.indexed.IndexGetFunc in project angel by Tencent.
the class GetValueOfIndexTask method sparseDouble.
public void sparseDouble(TaskContext tContext) {
long startGen = System.currentTimeMillis();
int[] index = genIndexs(feaNum, nnz);
long cost = System.currentTimeMillis() - startGen;
LOG.info("Gen index cost: " + cost + " ms.");
try {
MatrixClient sMatClient = tContext.getMatrix(SPARSE_DOUBLE_MAT);
// Set PS Model values
long startInc = System.currentTimeMillis();
SparseDoubleVector delt = new SparseDoubleVector(feaNum);
for (int i = 0; i < feaNum; i++) delt.set(i, (double) i);
sMatClient.increment(0, delt);
sMatClient.clock().get();
long costInc = System.currentTimeMillis() - startInc;
LOG.info("Increment delt cost " + costInc + " ms.");
// Wait for all tasks finish this clock
sMatClient.getTaskContext().globalSync(sMatClient.getMatrixId());
// Get values of index array
long startGet = System.currentTimeMillis();
IndexGetFunc func = new IndexGetFunc(new IndexGetParam(tContext.getMatrix(DENSE_DOUBLE_MAT).getMatrixId(), 0, index));
SparseDoubleVector row = (SparseDoubleVector) ((GetRowResult) sMatClient.get(func)).getRow();
long costGet = System.currentTimeMillis() - startGet;
LOG.info("Get row of indexs cost " + costGet + " ms.");
} catch (Throwable e) {
throw new AngelException(e);
}
}
use of com.tencent.angel.ml.matrix.psf.get.enhance.indexed.IndexGetFunc in project angel by Tencent.
the class GetValueOfIndexTask method denseDouble.
public void denseDouble(TaskContext tContext) {
long startGen = System.currentTimeMillis();
int[] index = genIndexs(feaNum, nnz);
long cost = System.currentTimeMillis() - startGen;
LOG.info("Gen index cost: " + cost + " ms.");
try {
MatrixClient dMatClient = tContext.getMatrix(DENSE_DOUBLE_MAT);
// Set PS Model values
long startInc = System.currentTimeMillis();
DenseDoubleVector delt = new DenseDoubleVector(feaNum);
for (int i = 0; i < feaNum; i++) delt.set(i, (double) i);
dMatClient.increment(0, delt);
dMatClient.clock().get();
long costInc = System.currentTimeMillis() - startInc;
LOG.info("Increment delt cost " + costInc + " ms.");
// Wait for all tasks finish this clock
dMatClient.getTaskContext().globalSync(dMatClient.getMatrixId());
// Get values of index array
long startGet = System.currentTimeMillis();
IndexGetFunc func = new IndexGetFunc(new IndexGetParam(tContext.getMatrix(DENSE_DOUBLE_MAT).getMatrixId(), 0, index));
SparseDoubleVector row = (SparseDoubleVector) ((GetRowResult) dMatClient.get(func)).getRow();
long costGet = System.currentTimeMillis() - startGet;
LOG.info("Get row of indexs cost " + costGet + " ms.");
} catch (Throwable e) {
throw new AngelException(e);
}
}
Aggregations