use of com.tencent.angel.model.ModelLoadContext in project angel by Tencent.
the class MasterService method load.
/**
* Load model from file
*/
@Override
public LoadResponse load(RpcController controller, LoadRequest request) throws ServiceException {
if (context.getModelLoader().isLoading()) {
throw new ServiceException("Model is loading now, please wait");
}
ModelLoadContextProto loadContextProto = request.getLoadContext();
ModelLoadContext loadContext = ProtobufUtil.convert(loadContextProto);
List<MatrixLoadContext> needLoadMatrices = loadContext.getMatricesContext();
int size = needLoadMatrices.size();
for (int i = 0; i < size; i++) {
if (!context.getMatrixMetaManager().exist(needLoadMatrices.get(i).getMatrixName())) {
throw new ServiceException("matrix " + needLoadMatrices.get(i).getMatrixName() + " does not exist");
}
}
int requestId;
try {
requestId = context.getModelLoader().load(loadContext);
} catch (Throwable x) {
throw new ServiceException(x);
}
return LoadResponse.newBuilder().setRequestId(requestId).build();
}
use of com.tencent.angel.model.ModelLoadContext in project angel by Tencent.
the class AngelClient method load.
public void load(Set<String> matrixNames) {
// Check need load matrices
String loadPath = conf.get(AngelConf.ANGEL_LOAD_MODEL_PATH);
if (loadPath != null && !loadPath.isEmpty()) {
ModelLoadContext loadContext = new ModelLoadContext(loadPath);
int needLoadMatrixCount = 0;
for (String name : matrixNames) {
MatrixContext matrix = nameToMatrixMap.get(name);
if (matrix.getAttributes().get(MatrixConf.MATRIX_LOAD_PATH) != null) {
loadContext.addMatrix(new MatrixLoadContext(name));
needLoadMatrixCount++;
}
}
if (needLoadMatrixCount > 0) {
load(loadContext);
}
}
}
Aggregations