Search in sources :

Example 1 with SparseDescriptor

use of org.nd4j.linalg.api.shape.SparseDescriptor in project nd4j by deeplearning4j.

the class DirectSparseInfoProvider method createSparseInformation.

@Override
public DataBuffer createSparseInformation(int[] flags, long[] sparseOffsets, int[] hiddenDimensions, int underlyingRank) {
    SparseDescriptor descriptor = new SparseDescriptor(flags, sparseOffsets, hiddenDimensions, underlyingRank);
    if (!sparseCache.containsKey(descriptor)) {
        if (counter.get() < MAX_ENTRIES) {
            if (!sparseCache.containsKey(descriptor)) {
                counter.incrementAndGet();
                DataBuffer buffer = Shape.createSparseInformation(flags, sparseOffsets, hiddenDimensions, underlyingRank);
                sparseCache.put(descriptor, buffer);
                return buffer;
            }
        } else {
            return Shape.createSparseInformation(flags, sparseOffsets, hiddenDimensions, underlyingRank);
        }
    }
    return sparseCache.get(descriptor);
}
Also used : SparseDescriptor(org.nd4j.linalg.api.shape.SparseDescriptor) DataBuffer(org.nd4j.linalg.api.buffer.DataBuffer)

Example 2 with SparseDescriptor

use of org.nd4j.linalg.api.shape.SparseDescriptor in project nd4j by deeplearning4j.

the class DirectSparseInfoProvider method createSparseInformation.

@Override
public DataBuffer createSparseInformation(int[] flags, long[] sparseOffsets, int[] hiddenDimensions, int underlyingRank) {
    SparseDescriptor descriptor = new SparseDescriptor(flags, sparseOffsets, hiddenDimensions, underlyingRank);
    if (!sparseCache.containsKey(descriptor)) {
        if (counter.get() < MAX_ENTRIES) {
            if (!sparseCache.containsKey(descriptor)) {
                counter.incrementAndGet();
                DataBuffer buffer = Shape.createSparseInformation(flags, sparseOffsets, hiddenDimensions, underlyingRank);
                sparseCache.put(descriptor, buffer);
                return buffer;
            }
        } else {
            return Shape.createSparseInformation(flags, sparseOffsets, hiddenDimensions, underlyingRank);
        }
    }
    return sparseCache.get(descriptor);
}
Also used : SparseDescriptor(org.nd4j.linalg.api.shape.SparseDescriptor) DataBuffer(org.nd4j.linalg.api.buffer.DataBuffer)

Aggregations

DataBuffer (org.nd4j.linalg.api.buffer.DataBuffer)2 SparseDescriptor (org.nd4j.linalg.api.shape.SparseDescriptor)2