use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam in project angel by Tencent.
the class GetNodesParam method split.
@Override
public List<PartitionGetParam> split() {
List<PartitionKey> parts = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
List<PartitionGetParam> params = new ArrayList<>();
Map<Integer, PartitionKey> pkeys = new HashMap<>();
for (PartitionKey pkey : parts) {
pkeys.put(pkey.getPartitionId(), pkey);
}
for (int i = 0; i < partitionIds.length; i++) {
params.add(new PartitionGetParam(matrixId, pkeys.get(partitionIds[i])));
}
return params;
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam in project angel by Tencent.
the class GetNodeFeats method merge.
@Override
public GetResult merge(List<PartitionGetResult> partResults) {
Int2ObjectArrayMap<PartitionGetResult> partIdToResultMap = new Int2ObjectArrayMap<>(partResults.size());
for (PartitionGetResult result : partResults) {
partIdToResultMap.put(((PartGetNodeFeatsResult) result).getPartId(), result);
}
GetNodeFeatsParam param = (GetNodeFeatsParam) getParam();
long[] nodeIds = param.getNodeIds();
List<PartitionGetParam> partParams = param.getPartParams();
Long2ObjectOpenHashMap<IntFloatVector> results = new Long2ObjectOpenHashMap<>(nodeIds.length);
int size = partResults.size();
for (int i = 0; i < size; i++) {
PartGetNodeFeatsParam partParam = (PartGetNodeFeatsParam) partParams.get(i);
PartGetNodeFeatsResult partResult = (PartGetNodeFeatsResult) partIdToResultMap.get(partParam.getPartKey().getPartitionId());
int start = partParam.getStartIndex();
int end = partParam.getEndIndex();
IntFloatVector[] feats = partResult.getFeats();
for (int j = start; j < end; j++) {
if (feats[j - start] != null) {
results.put(nodeIds[j], feats[j - start]);
}
}
}
return new GetNodeFeatsResult(results);
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam in project angel by Tencent.
the class SampleParam method split.
@Override
public List<PartitionGetParam> split() {
// Get matrix meta
MatrixMeta meta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
PartitionKey[] parts = meta.getPartitionKeys();
// Split
KeyPart[] nodeIdsParts = RouterUtils.split(meta, 0, nodeIds, false);
// Generate Part psf get param
List<PartitionGetParam> partParams = new ArrayList<>(parts.length);
assert parts.length == nodeIdsParts.length;
for (int i = 0; i < parts.length; i++) {
if (nodeIdsParts[i] != null && nodeIdsParts[i].size() > 0) {
partParams.add(new PartSampleParam(matrixId, parts[i], nodeIdsParts[i], sampleType));
}
}
return partParams;
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam in project angel by Tencent.
the class DotParam method split.
@Override
public List<PartitionGetParam> split() {
List<PartitionKey> pkeys = PSAgentContext.get().getMatrixMetaManager().getPartitions(matrixId);
List<PartitionGetParam> params = new ArrayList<>();
for (PartitionKey pkey : pkeys) {
params.add(new DotPartitionParam(matrixId, pkey, dataBuf, bufLength));
}
return params;
}
use of com.tencent.angel.ml.matrix.psf.get.base.PartitionGetParam in project angel by Tencent.
the class LongKeysGetParam method split.
@Override
public List<PartitionGetParam> split() {
// Get matrix meta
MatrixMeta meta = PSAgentContext.get().getMatrixMetaManager().getMatrixMeta(matrixId);
PartitionKey[] parts = meta.getPartitionKeys();
// Split
KeyPart[] nodeIdsParts = RouterUtils.split(meta, 0, nodeIds, false);
// Generate Part psf get param
List<PartitionGetParam> partParams = new ArrayList<>(parts.length);
assert parts.length == nodeIdsParts.length;
for (int i = 0; i < parts.length; i++) {
if (nodeIdsParts[i] != null && nodeIdsParts[i].size() > 0) {
partParams.add(new GeneralPartGetParam(matrixId, parts[i], nodeIdsParts[i]));
}
}
return partParams;
}
Aggregations