Search in sources :

Example 26 with ServerRow

use of com.tencent.angel.ps.storage.vector.ServerRow in project angel by Tencent.

the class IndexGetRowsHandler method handle.

@Override
public ResponseData handle(RequestHeader header, RequestData data) throws Exception {
    IndexPartGetRowsRequest request = (IndexPartGetRowsRequest) data;
    int[] rowIds = request.getRowIds();
    KeyPart keyPart = request.getKeyPart();
    ServerRow[] rows = new ServerRow[rowIds.length];
    ValuePart[] results = new ValuePart[rowIds.length];
    for (int i = 0; i < rowIds.length; i++) {
        rows[i] = context.getMatrixStorageManager().getRow(header.matrixId, rowIds[i], header.partId);
        rows[i].startRead();
        try {
            results[i] = ServerRowUtils.getByKeys(rows[i], keyPart);
        } finally {
            rows[i].endRead();
        }
    }
    IndexPartGetRowsResponse response = new IndexPartGetRowsResponse(results);
    return response;
}
Also used : IndexPartGetRowsRequest(com.tencent.angel.ps.server.data.request.IndexPartGetRowsRequest) ValuePart(com.tencent.angel.psagent.matrix.transport.router.ValuePart) IndexPartGetRowsResponse(com.tencent.angel.ps.server.data.response.IndexPartGetRowsResponse) KeyPart(com.tencent.angel.psagent.matrix.transport.router.KeyPart) ServerRow(com.tencent.angel.ps.storage.vector.ServerRow)

Example 27 with ServerRow

use of com.tencent.angel.ps.storage.vector.ServerRow in project angel by Tencent.

the class ServerRowsStorage method init.

/**
 * Init the server rows in the storage
 *
 * @param partKey partition key
 * @param rowType row type
 * @param estElemNum estimate element number
 * @param valueClass row element type
 */
public void init(PartitionKey partKey, RowType rowType, long estElemNum, Class<? extends IElement> valueClass, RouterType routerType) {
    int rowStart = partKey.getStartRow();
    int rowEnd = partKey.getEndRow();
    long startCol = partKey.getStartCol();
    long endCol = partKey.getEndCol();
    if (estElemNum < 0) {
        estElemNum = 0;
    }
    for (int rowIndex = rowStart; rowIndex < rowEnd; rowIndex++) {
        ServerRow row = ServerRowFactory.createServerRow(rowIndex, rowType, startCol, endCol, (int) estElemNum, valueClass, routerType);
        row.init();
        putRow(rowIndex, row);
    }
}
Also used : ServerRow(com.tencent.angel.ps.storage.vector.ServerRow)

Example 28 with ServerRow

use of com.tencent.angel.ps.storage.vector.ServerRow in project angel by Tencent.

the class QuantifyDoubleFunc method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    RowBasedPartition part = (RowBasedPartition) psContext.getMatrixStorageManager().getPart(partParam.getMatrixId(), partParam.getPartKey().getPartitionId());
    if (part != null) {
        QuantifyDoublePartUParam cp = (QuantifyDoublePartUParam) partParam;
        ServerRow row = part.getRow(cp.getRowId());
        if (row != null) {
            update(row, cp.getArraySlice());
        }
    }
}
Also used : ServerRow(com.tencent.angel.ps.storage.vector.ServerRow) QuantifyDoublePartUParam(com.tencent.angel.ml.psf.compress.QuantifyDoubleParam.QuantifyDoublePartUParam) RowBasedPartition(com.tencent.angel.ps.storage.partition.RowBasedPartition)

Example 29 with ServerRow

use of com.tencent.angel.ps.storage.vector.ServerRow in project angel by Tencent.

the class QuantifyFloatFunc method partitionUpdate.

@Override
public void partitionUpdate(PartitionUpdateParam partParam) {
    RowBasedPartition part = (RowBasedPartition) psContext.getMatrixStorageManager().getPart(partParam.getMatrixId(), partParam.getPartKey().getPartitionId());
    if (part != null) {
        QuantifyFloatPartParam cp = (QuantifyFloatPartParam) partParam;
        ServerRow row = part.getRow(cp.getRowId());
        if (row != null) {
            update(row, cp.getArraySlice());
        }
    }
}
Also used : QuantifyFloatPartParam(com.tencent.angel.ml.psf.compress.QuantifyFloatParam.QuantifyFloatPartParam) ServerRow(com.tencent.angel.ps.storage.vector.ServerRow) RowBasedPartition(com.tencent.angel.ps.storage.partition.RowBasedPartition)

Example 30 with ServerRow

use of com.tencent.angel.ps.storage.vector.ServerRow in project angel by Tencent.

the class AdaDeltaUpdateFunc method update.

@Override
public void update(RowBasedPartition partition, int factor, double[] scalars) {
    double epsilon = scalars[0];
    double alpha = scalars[1];
    double beta = scalars[2];
    double lr = scalars[3];
    double l1RegParam = scalars[4];
    double l2RegParam = scalars[5];
    double epoch = (int) scalars[6];
    double batchSize = (int) scalars[7];
    for (int f = 0; f < factor; f++) {
        ServerRow gradientServerRow = partition.getRow(f + 3 * factor);
        try {
            gradientServerRow.startWrite();
            Vector weight = ServerRowUtils.getVector(partition.getRow(f));
            Vector square1 = ServerRowUtils.getVector(partition.getRow(f + factor));
            Vector square2 = ServerRowUtils.getVector(partition.getRow(f + 2 * factor));
            Vector gradient = ServerRowUtils.getVector(gradientServerRow);
            if (batchSize > 1) {
                gradient.idiv(batchSize);
            }
            OptFuncs.iexpsmoothing2(square1, gradient, alpha);
            Vector hessian = OptFuncs.adadeltahessian(square1, square2);
            if (l2RegParam != 0) {
                gradient.iaxpy(weight, l2RegParam);
            }
            OptFuncs.iadadeltadelta(gradient, hessian, l2RegParam);
            weight.isub(gradient);
            OptFuncs.iexpsmoothing2(square2, gradient, beta);
            if (l1RegParam != 0) {
                OptFuncs.iadadeltathredshold(weight, hessian, l1RegParam, l2RegParam);
            }
            gradient.clear();
        } finally {
            gradientServerRow.endWrite();
        }
    }
}
Also used : ServerRow(com.tencent.angel.ps.storage.vector.ServerRow) Vector(com.tencent.angel.ml.math2.vector.Vector)

Aggregations

ServerRow (com.tencent.angel.ps.storage.vector.ServerRow)42 Vector (com.tencent.angel.ml.math2.vector.Vector)13 RowBasedPartition (com.tencent.angel.ps.storage.partition.RowBasedPartition)6 PartIncrementRowsParam (com.tencent.angel.ml.matrix.psf.update.update.PartIncrementRowsParam)5 RowUpdateSplit (com.tencent.angel.psagent.matrix.oplog.cache.RowUpdateSplit)5 ArrayList (java.util.ArrayList)5 PartitionKey (com.tencent.angel.PartitionKey)4 ServerIntIntRow (com.tencent.angel.ps.storage.vector.ServerIntIntRow)4 AngelException (com.tencent.angel.exception.AngelException)2 FloatVector (com.tencent.angel.ml.math2.vector.FloatVector)2 RowType (com.tencent.angel.ml.matrix.RowType)2 PartitionGetRowsParam (com.tencent.angel.ml.matrix.psf.get.getrows.PartitionGetRowsParam)2 GetRowSplitResponse (com.tencent.angel.ps.server.data.response.GetRowSplitResponse)2 GetRowsSplitResponse (com.tencent.angel.ps.server.data.response.GetRowsSplitResponse)2 Response (com.tencent.angel.ps.server.data.response.Response)2 MatrixStorageManager (com.tencent.angel.ps.storage.MatrixStorageManager)2 ServerMatrix (com.tencent.angel.ps.storage.matrix.ServerMatrix)2 ServerPartition (com.tencent.angel.ps.storage.partition.ServerPartition)2 ServerRowsStorage (com.tencent.angel.ps.storage.partition.storage.ServerRowsStorage)2 KeyPart (com.tencent.angel.psagent.matrix.transport.router.KeyPart)2