Search in sources :

Example 1 with Vector

use of com.tencent.angel.ml.math2.vector.Vector in project angel by Tencent.

the class RangeRouterUtils method splitLongLongVector.

public static KeyValuePart[] splitLongLongVector(MatrixMeta matrixMeta, LongLongVector vector) {
    LongLongVectorStorage storage = vector.getStorage();
    if (storage.isSparse()) {
        // Get keys and values
        LongLongSparseVectorStorage sparseStorage = (LongLongSparseVectorStorage) storage;
        long[] keys = sparseStorage.getIndices();
        long[] values = sparseStorage.getValues();
        return split(matrixMeta, vector.getRowId(), keys, values, false);
    } else {
        // Key and value array pair
        LongLongSortedVectorStorage sortStorage = (LongLongSortedVectorStorage) storage;
        long[] keys = sortStorage.getIndices();
        long[] values = sortStorage.getValues();
        return split(matrixMeta, vector.getRowId(), keys, values, true);
    }
}
Also used : LongLongSortedVectorStorage(com.tencent.angel.ml.math2.storage.LongLongSortedVectorStorage) LongLongVectorStorage(com.tencent.angel.ml.math2.storage.LongLongVectorStorage) LongLongSparseVectorStorage(com.tencent.angel.ml.math2.storage.LongLongSparseVectorStorage)

Example 2 with Vector

use of com.tencent.angel.ml.math2.vector.Vector in project angel by Tencent.

the class RangeRouterUtils method splitIntDoubleVector.

public static KeyValuePart[] splitIntDoubleVector(MatrixMeta matrixMeta, IntDoubleVector vector) {
    IntDoubleVectorStorage storage = vector.getStorage();
    if (storage.isSparse()) {
        // Get keys and values
        IntDoubleSparseVectorStorage sparseStorage = (IntDoubleSparseVectorStorage) storage;
        int[] keys = sparseStorage.getIndices();
        double[] values = sparseStorage.getValues();
        return split(matrixMeta, vector.getRowId(), keys, values, false);
    } else if (storage.isDense()) {
        // Get values
        IntDoubleDenseVectorStorage denseStorage = (IntDoubleDenseVectorStorage) storage;
        double[] values = denseStorage.getValues();
        return split(matrixMeta, vector.getRowId(), values);
    } else {
        // Key and value array pair
        IntDoubleSortedVectorStorage sortStorage = (IntDoubleSortedVectorStorage) storage;
        int[] keys = sortStorage.getIndices();
        double[] values = sortStorage.getValues();
        return split(matrixMeta, vector.getRowId(), keys, values, true);
    }
}
Also used : IntDoubleSparseVectorStorage(com.tencent.angel.ml.math2.storage.IntDoubleSparseVectorStorage) IntDoubleDenseVectorStorage(com.tencent.angel.ml.math2.storage.IntDoubleDenseVectorStorage) IntDoubleVectorStorage(com.tencent.angel.ml.math2.storage.IntDoubleVectorStorage) IntDoubleSortedVectorStorage(com.tencent.angel.ml.math2.storage.IntDoubleSortedVectorStorage)

Example 3 with Vector

use of com.tencent.angel.ml.math2.vector.Vector in project angel by Tencent.

the class CompIntDoubleVectorSplitter method split.

@Override
public Map<PartitionKey, RowUpdateSplit> split(Vector vector, List<PartitionKey> parts) {
    IntDoubleVector[] vecParts = ((CompIntDoubleVector) vector).getPartitions();
    assert vecParts.length == parts.size();
    Map<PartitionKey, RowUpdateSplit> updateSplitMap = new HashMap<>(parts.size());
    for (int i = 0; i < vecParts.length; i++) {
        updateSplitMap.put(parts.get(i), new CompIntDoubleRowUpdateSplit(vector.getRowId(), vecParts[i], (int) (parts.get(i).getEndCol() - parts.get(i).getStartCol())));
    }
    return updateSplitMap;
}
Also used : HashMap(java.util.HashMap) PartitionKey(com.tencent.angel.PartitionKey) CompIntDoubleRowUpdateSplit(com.tencent.angel.psagent.matrix.oplog.cache.CompIntDoubleRowUpdateSplit) RowUpdateSplit(com.tencent.angel.psagent.matrix.oplog.cache.RowUpdateSplit) CompIntDoubleVector(com.tencent.angel.ml.math2.vector.CompIntDoubleVector) CompIntDoubleRowUpdateSplit(com.tencent.angel.psagent.matrix.oplog.cache.CompIntDoubleRowUpdateSplit) IntDoubleVector(com.tencent.angel.ml.math2.vector.IntDoubleVector) CompIntDoubleVector(com.tencent.angel.ml.math2.vector.CompIntDoubleVector)

Example 4 with Vector

use of com.tencent.angel.ml.math2.vector.Vector in project angel by Tencent.

the class CompLongDoubleVectorSplitter method split.

@Override
public Map<PartitionKey, RowUpdateSplit> split(Vector vector, List<PartitionKey> parts) {
    LongDoubleVector[] vecParts = ((CompLongDoubleVector) vector).getPartitions();
    assert vecParts.length == parts.size();
    Map<PartitionKey, RowUpdateSplit> updateSplitMap = new HashMap<>(parts.size());
    for (int i = 0; i < vecParts.length; i++) {
        updateSplitMap.put(parts.get(i), new CompLongDoubleRowUpdateSplit(vector.getRowId(), vecParts[i]));
    }
    return updateSplitMap;
}
Also used : CompLongDoubleVector(com.tencent.angel.ml.math2.vector.CompLongDoubleVector) LongDoubleVector(com.tencent.angel.ml.math2.vector.LongDoubleVector) CompLongDoubleVector(com.tencent.angel.ml.math2.vector.CompLongDoubleVector) HashMap(java.util.HashMap) PartitionKey(com.tencent.angel.PartitionKey) RowUpdateSplit(com.tencent.angel.psagent.matrix.oplog.cache.RowUpdateSplit) CompLongDoubleRowUpdateSplit(com.tencent.angel.psagent.matrix.oplog.cache.CompLongDoubleRowUpdateSplit) CompLongDoubleRowUpdateSplit(com.tencent.angel.psagent.matrix.oplog.cache.CompLongDoubleRowUpdateSplit)

Example 5 with Vector

use of com.tencent.angel.ml.math2.vector.Vector in project angel by Tencent.

the class RangeRouterUtils method splitLongIntVector.

public static KeyValuePart[] splitLongIntVector(MatrixMeta matrixMeta, LongIntVector vector) {
    LongIntVectorStorage storage = vector.getStorage();
    if (storage.isSparse()) {
        // Get keys and values
        LongIntSparseVectorStorage sparseStorage = (LongIntSparseVectorStorage) storage;
        long[] keys = sparseStorage.getIndices();
        int[] values = sparseStorage.getValues();
        return split(matrixMeta, vector.getRowId(), keys, values, false);
    } else {
        // Key and value array pair
        LongIntSortedVectorStorage sortStorage = (LongIntSortedVectorStorage) storage;
        long[] keys = sortStorage.getIndices();
        int[] values = sortStorage.getValues();
        return split(matrixMeta, vector.getRowId(), keys, values, true);
    }
}
Also used : LongIntVectorStorage(com.tencent.angel.ml.math2.storage.LongIntVectorStorage) LongIntSortedVectorStorage(com.tencent.angel.ml.math2.storage.LongIntSortedVectorStorage) LongIntSparseVectorStorage(com.tencent.angel.ml.math2.storage.LongIntSparseVectorStorage)

Aggregations

IntDoubleVectorStorage (com.tencent.angel.ml.math2.storage.IntDoubleVectorStorage)189 IntFloatVectorStorage (com.tencent.angel.ml.math2.storage.IntFloatVectorStorage)188 LongFloatVectorStorage (com.tencent.angel.ml.math2.storage.LongFloatVectorStorage)188 LongIntVectorStorage (com.tencent.angel.ml.math2.storage.LongIntVectorStorage)186 LongDoubleVectorStorage (com.tencent.angel.ml.math2.storage.LongDoubleVectorStorage)185 IntLongVectorStorage (com.tencent.angel.ml.math2.storage.IntLongVectorStorage)183 LongLongVectorStorage (com.tencent.angel.ml.math2.storage.LongLongVectorStorage)183 IntIntVectorStorage (com.tencent.angel.ml.math2.storage.IntIntVectorStorage)182 ObjectIterator (it.unimi.dsi.fastutil.objects.ObjectIterator)170 Storage (com.tencent.angel.ml.math2.storage.Storage)169 LongDoubleSparseVectorStorage (com.tencent.angel.ml.math2.storage.LongDoubleSparseVectorStorage)127 LongFloatSparseVectorStorage (com.tencent.angel.ml.math2.storage.LongFloatSparseVectorStorage)125 LongLongSparseVectorStorage (com.tencent.angel.ml.math2.storage.LongLongSparseVectorStorage)121 IntDoubleSparseVectorStorage (com.tencent.angel.ml.math2.storage.IntDoubleSparseVectorStorage)119 IntFloatSparseVectorStorage (com.tencent.angel.ml.math2.storage.IntFloatSparseVectorStorage)119 LongIntSparseVectorStorage (com.tencent.angel.ml.math2.storage.LongIntSparseVectorStorage)119 IntDoubleSortedVectorStorage (com.tencent.angel.ml.math2.storage.IntDoubleSortedVectorStorage)118 LongDoubleSortedVectorStorage (com.tencent.angel.ml.math2.storage.LongDoubleSortedVectorStorage)118 IntFloatSortedVectorStorage (com.tencent.angel.ml.math2.storage.IntFloatSortedVectorStorage)117 LongFloatSortedVectorStorage (com.tencent.angel.ml.math2.storage.LongFloatSortedVectorStorage)117