org.nd4j.linalg.api.ops.aggregates.Batch Java Examples

The following examples show how to use org.nd4j.linalg.api.ops.aggregates.Batch. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: CudaExecutioner.java    From nd4j with Apache License 2.0 5 votes vote down vote up
@Override
public void exec(List<Aggregate> batch) {
    if (batch.size() == 0)
        return;

    List<Batch<Aggregate>> batches = Batch.getBatches(batch, 8192);
    for (Batch<Aggregate> single : batches) {
        this.exec(single);
    }

    CudaContext context = (CudaContext) AtomicAllocator.getInstance().getDeviceContext().getContext();
    context.syncOldStream();
}
 
Example #2
Source File: NativeOpExecutioner.java    From nd4j with Apache License 2.0 5 votes vote down vote up
protected <T extends Aggregate> Pointer getPointer(Batch<T> batch) {
    if (batchPointers.get() == null)
        batchPointers.set(new HashMap<Integer, Pointer>());

    if (!batchPointers.get().containsKey(batch.opNum())) {
        IntPointer pointer = new IntPointer(batch.getSample().getRequiredBatchMemorySize() / 4);
        batchPointers.get().put(batch.opNum(), pointer);
        return pointer;
    }

    return batchPointers.get().get(batch.opNum());
}
 
Example #3
Source File: NativeOpExecutioner.java    From nd4j with Apache License 2.0 5 votes vote down vote up
/**
 * This method takes arbitrary
 * sized list of {@link Aggregate},
 * and packs them into batches
 * Note here that this is mainly used for random number generation
 * for {@link RandomOp} and things like {@link org.nd4j.linalg.api.rng.distribution.Distribution}
 * @param batch the list of {@link Aggregate} to
 *              execute upon
 */
@Override
public void exec(List<Aggregate> batch) {
    if (batch.size() == 0)
        return;

    List<Batch<Aggregate>> batches = Batch.getBatches(batch);
    for (Batch<Aggregate> single : batches) {
        this.exec(single);
    }
}
 
Example #4
Source File: CudaExecutioner.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
@Override
public void exec(List<Aggregate> batch) {
    if (batch.size() == 0)
        return;

    List<Batch<Aggregate>> batches = Batch.getBatches(batch, 8192);
    for (Batch<Aggregate> single : batches) {
        this.exec(single);
    }

    val context = AtomicAllocator.getInstance().getDeviceContext();
    context.syncOldStream();
}
 
Example #5
Source File: NativeOpExecutioner.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
protected <T extends Aggregate> Pointer getPointer(Batch<T> batch) {
    if (batchPointers.get() == null)
        batchPointers.set(new HashMap<Integer, Pointer>());

    if (!batchPointers.get().containsKey(batch.opNum())) {
        val pointer = new IntPointer(batch.getSample().getRequiredBatchMemorySize() / 4 );
        batchPointers.get().put(batch.opNum(), pointer);
        return pointer;
    }

    return batchPointers.get().get(batch.opNum());
}
 
Example #6
Source File: NativeOpExecutioner.java    From deeplearning4j with Apache License 2.0 5 votes vote down vote up
/**
 * This method takes arbitrary
 * sized list of {@link Aggregate},
 * and packs them into batches
 * Note here that this is mainly used for random number generation
 * for {@link RandomOp} and things like {@link org.nd4j.linalg.api.rng.distribution.Distribution}
 * @param batch the list of {@link Aggregate} to
 *              execute upon
 */
@Override
public void exec(List<Aggregate> batch) {
    if (batch.size() == 0)
        return;

    List<Batch<Aggregate>> batches = Batch.getBatches(batch);
    for (Batch<Aggregate> single : batches) {
        this.exec(single);
    }
}
 
Example #7
Source File: CudaExecutioner.java    From nd4j with Apache License 2.0 4 votes vote down vote up
protected <T extends Aggregate> DataBuffer getBuffer(Batch<T> batch) {
    DataBuffer buffer = Nd4j.getDataBufferFactory().createInt(batch.getSample().getRequiredBatchMemorySize() * 4,
            false);
    batch.setParamsSurface(buffer);
    return buffer;
}
 
Example #8
Source File: DefaultOpExecutioner.java    From nd4j with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends Aggregate> void exec(Batch<T> batch) {
    throw new UnsupportedOperationException();
}
 
Example #9
Source File: CudaExecutioner.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
protected <T extends Aggregate> DataBuffer getBuffer(Batch<T> batch) {
    DataBuffer buffer = Nd4j.getDataBufferFactory().createInt(batch.getSample().getRequiredBatchMemorySize() * 4,
            false);
    batch.setParamsSurface(buffer);
    return buffer;
}
 
Example #10
Source File: CudaExecutioner.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends Aggregate> void exec(Batch<T> batch) {
    throw new UnsupportedOperationException("Pew-pew");
}
 
Example #11
Source File: DefaultOpExecutioner.java    From deeplearning4j with Apache License 2.0 4 votes vote down vote up
@Override
public <T extends Aggregate> void exec(Batch<T> batch) {
    throw new UnsupportedOperationException();
}
 
Example #12
Source File: SameDiffOpExecutioner.java    From nd4j with Apache License 2.0 2 votes vote down vote up
/**
 * This method executes previously built batch
 *
 * @param batch
 */
@Override
public <T extends Aggregate> void exec(Batch<T> batch) {

}
 
Example #13
Source File: OpExecutioner.java    From nd4j with Apache License 2.0 2 votes vote down vote up
/**
 * This method executes previously built batch
 *
 * @param batch
 */
<T extends Aggregate> void exec(Batch<T> batch);
 
Example #14
Source File: OpExecutioner.java    From deeplearning4j with Apache License 2.0 2 votes vote down vote up
/**
 * This method executes previously built batch
 *
 * @param batch
 */
<T extends Aggregate> void exec(Batch<T> batch);