Backends/SiaNet.Backend.TensorSharp/Cuda/DeviceCode/SpatialMaxPoolKernels.cs
/// <summary>
/// Spatials the maximum pooling backward.
/// </summary>
/// <param name="input">The input.</param>
/// <param name="gradOutput">The grad output.</param>
/// <param name="gradInput">The grad input.</param>
/// <param name="indices">The indices.</param>
/// <param name="cd">The cd.</param>
/// <param name="ceilMode">if set to <c>true</c> [ceil mode].</param>
Spatials the maximum pooling backward.
Spatials the maximum pooling backward .
public void SpatialMaxPoolingBackward(NDArray input, NDArray gradOutput, NDArray gradInput, NDArray indices, ConvolutionDesc2d cd, bool ceilMode)
        {
            var context = CudaHelpers.TSContextForTensor(gradOutput);
            var cudaContext = context.CudaContextForTensor(gradOutput);
            var dimw = 3;
            var dimh = 2;
            var dimc = 1;
            var nbatch = input.Shape[0];
            var nslices = input.Shape[dimc];
            var iheight = input.Shape[dimh];
            var iwidth = input.Shape[dimw];
            var owidth = gradOutput.Shape[dimw];
            var oheight = gradOutput.Shape[dimh];
            using (var gradOutputContig = Ops.AsContiguous(gradOutput))
            {
                var gradOutputPtr = CudaHelpers.GetBufferStart(gradOutputContig);
                var indicesPtr = CudaHelpers.GetBufferStart(indices);
                var gradInputPtr = CudaHelpers.GetBufferStart(gradInput);
                var count = (int)input.ElementCount();
                Invoke(context, cudaContext, "MaxPoolBackward", new dim3(NNThreads.NumBlocks(count)), new dim3(NNThreads.NumThreads), 0, CUstream.NullStream,
                    count, gradOutputPtr, indicesPtr, nbatch, nslices, iheight, iwidth, oheight, owidth,
                    cd.kH, cd.kW, cd.dH, cd.dW, cd.padH, cd.padW, gradInputPtr);
            }
        }
public void SpatialMaxPoolingBackward ( NDArray input , NDArray gradOutput , NDArray gradInput , NDArray indices , ConvolutionDesc2d cd , bool ceilMode ) { var context = CudaHelpers . TSContextForTensor ( gradOutput ) ; var cudaContext = context . CudaContextForTensor ( gradOutput ) ; var dimw = 3 ; var dimh = 2 ; var dimc = 1 ; var nbatch = input . Shape [ 0 ] ; var nslices = input . Shape [ dimc ] ; var iheight = input . Shape [ dimh ] ; var iwidth = input . Shape [ dimw ] ; var owidth = gradOutput . Shape [ dimw ] ; var oheight = gradOutput . Shape [ dimh ] ; using ( var gradOutputContig = Ops . AsContiguous ( gradOutput ) ) { var gradOutputPtr = CudaHelpers . GetBufferStart ( gradOutputContig ) ; var indicesPtr = CudaHelpers . GetBufferStart ( indices ) ; var gradInputPtr = CudaHelpers . GetBufferStart ( gradInput ) ; var count = ( int ) input . ElementCount ( ) ; Invoke ( context , cudaContext , " " , new dim3 ( NNThreads . NumBlocks ( count ) ) , new dim3 ( NNThreads . NumThreads ) , 0 , CUstream . NullStream , count , gradOutputPtr , indicesPtr , nbatch , nslices , iheight , iwidth , oheight , owidth , cd . kH , cd . kW , cd . dH , cd . dW , cd . padH , cd . padW , gradInputPtr ) ; } }
Spatials the maximum pooling backward.
Spatials the maximum pooling backward .
input
NDArray
None
gradOutput
NDArray
The grad output.
The grad output .
gradInput
NDArray
The grad input.
The grad input .
indices
NDArray
None
cd
ConvolutionDesc2d
None
ceilMode
bool
if set to true
if set to true