Search in sources :

Example 6 with IntLongDenseVectorStorage

use of com.tencent.angel.ml.math2.storage.IntLongDenseVectorStorage in project angel by Tencent.

the class CompIntLongRowUpdateSplit method serialize.

@Override
public void serialize(ByteBuf buf) {
    super.serialize(buf);
    IntLongVectorStorage storage = split.getStorage();
    if (storage instanceof IntLongSparseVectorStorage) {
        buf.writeInt(storage.size());
        ObjectIterator<Int2LongMap.Entry> iter = storage.entryIterator();
        Int2LongMap.Entry entry;
        while (iter.hasNext()) {
            entry = iter.next();
            buf.writeInt(entry.getIntKey());
            buf.writeLong(entry.getLongValue());
        }
    } else if (storage instanceof IntLongSortedVectorStorage) {
        buf.writeInt(storage.size());
        int[] indices = storage.getIndices();
        long[] values = storage.getValues();
        for (int i = 0; i < indices.length; i++) {
            buf.writeInt(indices[i]);
            buf.writeLong(values[i]);
        }
    } else if (storage instanceof IntLongDenseVectorStorage) {
        long[] values = storage.getValues();
        int writeSize = values.length < maxItemNum ? values.length : maxItemNum;
        buf.writeInt(writeSize);
        for (int i = 0; i < writeSize; i++) {
            buf.writeLong(values[i]);
        }
    } else {
        throw new UnsupportedOperationException("unsupport split for storage " + storage.getClass().getName());
    }
}
Also used : IntLongSparseVectorStorage(com.tencent.angel.ml.math2.storage.IntLongSparseVectorStorage) IntLongVectorStorage(com.tencent.angel.ml.math2.storage.IntLongVectorStorage) IntLongSortedVectorStorage(com.tencent.angel.ml.math2.storage.IntLongSortedVectorStorage) Int2LongMap(it.unimi.dsi.fastutil.ints.Int2LongMap) IntLongDenseVectorStorage(com.tencent.angel.ml.math2.storage.IntLongDenseVectorStorage)

Example 7 with IntLongDenseVectorStorage

use of com.tencent.angel.ml.math2.storage.IntLongDenseVectorStorage in project angel by Tencent.

the class RBIntLongMatrix method diag.

@Override
public Vector diag() {
    long[] resArr = new long[rows.length];
    for (int i = 0; i < rows.length; i++) {
        if (null == rows[i]) {
            resArr[i] = 0;
        } else {
            resArr[i] = rows[i].get(i);
        }
    }
    IntLongDenseVectorStorage storage = new IntLongDenseVectorStorage(resArr);
    return new IntLongVector(getMatrixId(), 0, getClock(), resArr.length, storage);
}
Also used : IntLongVector(com.tencent.angel.ml.math2.vector.IntLongVector) IntLongDenseVectorStorage(com.tencent.angel.ml.math2.storage.IntLongDenseVectorStorage)

Example 8 with IntLongDenseVectorStorage

use of com.tencent.angel.ml.math2.storage.IntLongDenseVectorStorage in project angel by Tencent.

the class RBCompLongLongMatrix method diag.

@Override
public Vector diag() {
    long[] resArr = new long[rows.length];
    for (int i = 0; i < rows.length; i++) {
        if (null == rows[i]) {
            resArr[i] = 0;
        } else {
            resArr[i] = rows[i].get(i);
        }
    }
    IntLongDenseVectorStorage storage = new IntLongDenseVectorStorage(resArr);
    return new IntLongVector(getMatrixId(), 0, getClock(), resArr.length, storage);
}
Also used : IntLongVector(com.tencent.angel.ml.math2.vector.IntLongVector) IntLongDenseVectorStorage(com.tencent.angel.ml.math2.storage.IntLongDenseVectorStorage)

Aggregations

IntLongDenseVectorStorage (com.tencent.angel.ml.math2.storage.IntLongDenseVectorStorage)8 IntLongVector (com.tencent.angel.ml.math2.vector.IntLongVector)5 IntLongSortedVectorStorage (com.tencent.angel.ml.math2.storage.IntLongSortedVectorStorage)3 IntLongSparseVectorStorage (com.tencent.angel.ml.math2.storage.IntLongSparseVectorStorage)3 IntLongVectorStorage (com.tencent.angel.ml.math2.storage.IntLongVectorStorage)3 Int2LongMap (it.unimi.dsi.fastutil.ints.Int2LongMap)2 CompIntLongVector (com.tencent.angel.ml.math2.vector.CompIntLongVector)1 IntDoubleVector (com.tencent.angel.ml.math2.vector.IntDoubleVector)1 IntFloatVector (com.tencent.angel.ml.math2.vector.IntFloatVector)1 IntIntVector (com.tencent.angel.ml.math2.vector.IntIntVector)1 LongDoubleVector (com.tencent.angel.ml.math2.vector.LongDoubleVector)1 LongFloatVector (com.tencent.angel.ml.math2.vector.LongFloatVector)1 LongIntVector (com.tencent.angel.ml.math2.vector.LongIntVector)1 LongLongVector (com.tencent.angel.ml.math2.vector.LongLongVector)1 Vector (com.tencent.angel.ml.math2.vector.Vector)1 IncrementRows (com.tencent.angel.ml.matrix.psf.update.update.IncrementRows)1 IncrementRowsParam (com.tencent.angel.ml.matrix.psf.update.update.IncrementRowsParam)1 MatrixClient (com.tencent.angel.psagent.matrix.MatrixClient)1 Worker (com.tencent.angel.worker.Worker)1