use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.
the class ModelLoader method loadToDoubleLongKeyMaps.
/**
* Load dense double model to long->double maps
*
* @param modelDir model save directory path
* @return model data
*/
public static Long2DoubleOpenHashMap[] loadToDoubleLongKeyMaps(String modelDir, Configuration conf) throws IOException {
// Load model meta
MatrixFilesMeta meta = getMeta(modelDir, conf);
RowType rowType = RowType.valueOf(meta.getRowType());
// Check row type
if (rowType != RowType.T_DOUBLE_SPARSE_LONGKEY && rowType != RowType.T_DOUBLE_SPARSE_LONGKEY_COMPONENT) {
throw new IOException("model row type is not sparse long double, you should check it");
}
// Load model
SparseDoubleLongKeyModel model = new SparseDoubleLongKeyModel(meta.getRow(), meta.getCol());
loadModel(modelDir, model, meta, conf);
return model.getModel();
}
use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.
the class ModelLoader method loadToFloatMaps.
/**
* Load dense double model to int->float maps
*
* @param modelDir model save directory path
* @return model data
*/
public static Int2FloatOpenHashMap[] loadToFloatMaps(String modelDir, Configuration conf) throws IOException {
// Load model meta
MatrixFilesMeta meta = getMeta(modelDir, conf);
RowType rowType = RowType.valueOf(meta.getRowType());
// Check row type
if (rowType != RowType.T_FLOAT_SPARSE && rowType != rowType.T_FLOAT_SPARSE_COMPONENT) {
throw new IOException("model row type is not sparse float, you should check it");
}
// Load model
SparseFloatModel model = new SparseFloatModel(meta.getRow(), meta.getCol());
loadModel(modelDir, model, meta, conf);
return model.getModel();
}
use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.
the class RowSplitCombineUtils method combineServerRowSplits.
/**
* Combine row splits of a single matrix row.
*
* @param rowSplits row splits
* @param matrixId matrix id
* @param rowIndex row index
* @return TVector merged row
*/
public static Vector combineServerRowSplits(List<ServerRow> rowSplits, int matrixId, int rowIndex) {
MatrixMeta matrixMeta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
RowType rowType = matrixMeta.getRowType();
switch(rowType) {
case T_DOUBLE_DENSE:
case T_DOUBLE_SPARSE:
return combineServerIntDoubleRowSplits(rowSplits, matrixMeta, rowIndex);
case T_FLOAT_DENSE:
case T_FLOAT_SPARSE:
return combineServerIntFloatRowSplits(rowSplits, matrixMeta, rowIndex);
case T_INT_DENSE:
case T_INT_SPARSE:
return combineServerIntIntRowSplits(rowSplits, matrixMeta, rowIndex);
case T_LONG_DENSE:
case T_LONG_SPARSE:
return combineServerIntLongRowSplits(rowSplits, matrixMeta, rowIndex);
case T_DOUBLE_SPARSE_LONGKEY:
return combineServerLongDoubleRowSplits(rowSplits, matrixMeta, rowIndex);
case T_FLOAT_SPARSE_LONGKEY:
return combineServerLongFloatRowSplits(rowSplits, matrixMeta, rowIndex);
case T_INT_SPARSE_LONGKEY:
return combineServerLongIntRowSplits(rowSplits, matrixMeta, rowIndex);
case T_LONG_SPARSE_LONGKEY:
return combineServerLongLongRowSplits(rowSplits, matrixMeta, rowIndex);
default:
throw new UnsupportedOperationException("Unsupport operation: merge " + rowType + " vector splits");
}
}
use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.
the class MergeUtils method combineServerRowSplits.
/**
* Combine row splits of a single matrix row.
*
* @param rowSplits row splits
* @param matrixId matrix id
* @param rowIndex row index
* @return TVector merged row
*/
public static Vector combineServerRowSplits(List<ServerRow> rowSplits, int matrixId, int rowIndex) {
MatrixMeta matrixMeta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
RowType rowType = matrixMeta.getRowType();
switch(rowType) {
case T_DOUBLE_DENSE:
case T_DOUBLE_SPARSE:
return combineServerIntDoubleRowSplits(rowSplits, matrixMeta, rowIndex);
case T_FLOAT_DENSE:
case T_FLOAT_SPARSE:
return combineServerIntFloatRowSplits(rowSplits, matrixMeta, rowIndex);
case T_INT_DENSE:
case T_INT_SPARSE:
return combineServerIntIntRowSplits(rowSplits, matrixMeta, rowIndex);
case T_LONG_DENSE:
case T_LONG_SPARSE:
return combineServerIntLongRowSplits(rowSplits, matrixMeta, rowIndex);
case T_DOUBLE_SPARSE_LONGKEY:
return combineServerLongDoubleRowSplits(rowSplits, matrixMeta, rowIndex);
case T_FLOAT_SPARSE_LONGKEY:
return combineServerLongFloatRowSplits(rowSplits, matrixMeta, rowIndex);
case T_INT_SPARSE_LONGKEY:
return combineServerLongIntRowSplits(rowSplits, matrixMeta, rowIndex);
case T_LONG_SPARSE_LONGKEY:
return combineServerLongLongRowSplits(rowSplits, matrixMeta, rowIndex);
default:
throw new UnsupportedOperationException("Unsupport operation: merge " + rowType + " vector splits");
}
}
use of com.tencent.angel.ml.matrix.RowType in project angel by Tencent.
the class MatrixOpLog method createMatrix.
private Matrix createMatrix(MatrixMeta meta) {
RowType rowType = meta.getRowType();
String opLogTypeStr = meta.getAttribute(MatrixConf.MATRIX_OPLOG_TYPE);
RowType opLogType;
if (opLogTypeStr == null) {
opLogType = rowType;
} else {
opLogType = RowType.valueOf(opLogTypeStr);
}
return MatrixFactory.createRBMatrix(opLogType, meta.getRowNum(), meta.getColNum(), meta.getBlockColNum());
}
Aggregations