cuda.forward.maxpooling.BackwardMaxPoolingKernel.cu Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of komputation Show documentation
Show all versions of komputation Show documentation
Komputation is a neural network framework for the JVM written in the Kotlin programming language.
__global__ void backwardMaxPoolingKernel (
int batchSize,
int* lengths,
float symbolForUnusedColumns,
int numberEntriesPerInstance,
int numberRows,
int* maxIndices,
float* chain,
float* result) {
int indexInstance = blockIdx.x;
int indexRow = blockIdx.y;
int indexColumn = threadIdx.x;
int startInstanceWithinBatch = indexInstance * numberEntriesPerInstance;
int startColumnWithinInstance = indexColumn * numberRows;
int indexEntryWithinBatch = startInstanceWithinBatch + startColumnWithinInstance + indexRow;
if(indexInstance < batchSize) {
int length = lengths[indexInstance];
if(indexColumn < length) {
int maxIndex = maxIndices[indexInstance * numberRows + indexRow];
if(indexEntryWithinBatch == maxIndex) {
result[indexEntryWithinBatch] = chain[indexInstance * numberRows + indexRow];
}
else {
result[indexEntryWithinBatch] = 0.0;
}
}
else {
result[indexEntryWithinBatch] = symbolForUnusedColumns;
}
}
else {
result[indexEntryWithinBatch] = symbolForUnusedColumns;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy