All Downloads are FREE. Search and download functionalities are using the official Maven repository.

cuda.forward.sigmoid.BackwardSigmoidKernel.cu Maven / Gradle / Ivy

Go to download

Komputation is a neural network framework for the JVM written in the Kotlin programming language.

There is a newer version: 0.12.5
Show newest version
#include "symbols/NaN.cuh"

__device__ float backwardSigmoid (float forward, float chain)
{

    return forward * (1.0f - forward) * chain;

}

__global__ void backwardSigmoidKernel (
    int batchSize,
    int numberRows,
    int numberEntriesPerInstance,
    int numberIterations,
    float *forward,
    float *chain,
    float *destination) {

    int indexInstance = blockIdx.x;
    int indexColumn = blockIdx.y;

    int startInstanceWithinBatch = indexInstance * numberEntriesPerInstance;
    int startColumnWithinInstance = indexColumn * numberRows;
    int startRowWithinColumn = threadIdx.x * numberIterations;

    int firstEntryWithinBatch = startInstanceWithinBatch + startColumnWithinInstance + startRowWithinColumn;
    int startNextColumn = startInstanceWithinBatch + startColumnWithinInstance + numberRows;

    if(firstEntryWithinBatch < startNextColumn) {

        int lastEntryWithinBatch = min(firstEntryWithinBatch + numberIterations, startNextColumn);

        if(indexInstance < batchSize) {

            for(int indexEntry = firstEntryWithinBatch; indexEntry < lastEntryWithinBatch; indexEntry++) {

                destination[indexEntry] = backwardSigmoid(forward[indexEntry], chain[indexEntry]);

            }

        }
        else {

            setToNan(destination, firstEntryWithinBatch, lastEntryWithinBatch);

        }

    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy