Backends/SiaNet.Backend.TensorSharp/Cuda/DeviceCode/ReduceDimIndexKernels.cs
/// <summary>
/// Runs the reduce index op.
/// </summary>
/// <param name="resultIndices">The result indices.</param>
/// <param name="src">The source.</param>
/// <param name="dimension">The dimension.</param>
/// <param name="init">The initialize.</param>
/// <param name="baseKernelName">Name of the base kernel.</param>
/// <returns>Tensor.</returns>
Runs the reduce index op.
Runs the reduce index op .
private NDArray RunReduceIndexOp(NDArray resultIndices, NDArray src, int dimension, Tuple<float, float> init, string baseKernelName)
        {
            var context = CudaHelpers.TSContextForTensor(src);
            var requiredOutputSize = (long[])src.Shape.Clone();
            requiredOutputSize[dimension] = 1;
            var writeTarget = TensorResultBuilder.GetWriteTarget(resultIndices, src.Allocator, DType.Float32, true, requiredOutputSize);
            using (var resultValueBuffer = new NDArray(src.Allocator, src.ElementType, requiredOutputSize))
            {
                if (dimension == src.DimensionCount - 1)
                {
                    ReduceIndexInnermostDim(context, resultValueBuffer, writeTarget, src, init, baseKernelName);
                }
                else
                {
                    ReduceIndexOuterDim(context, resultValueBuffer, writeTarget, src, dimension, init, baseKernelName);
                }
            }
            return writeTarget;
        }
private NDArray RunReduceIndexOp ( NDArray resultIndices , NDArray src , int dimension , Tuple < float , float > init , string baseKernelName ) { var context = CudaHelpers . TSContextForTensor ( src ) ; var requiredOutputSize = ( long [ ] ) src . Shape . Clone ( ) ; requiredOutputSize [ dimension ] = 1 ; var writeTarget = TensorResultBuilder . GetWriteTarget ( resultIndices , src . Allocator , DType . Float32 , true , requiredOutputSize ) ; using ( var resultValueBuffer = new NDArray ( src . Allocator , src . ElementType , requiredOutputSize ) ) { if ( dimension == src . DimensionCount - 1 ) { ReduceIndexInnermostDim ( context , resultValueBuffer , writeTarget , src , init , baseKernelName ) ; } else { ReduceIndexOuterDim ( context , resultValueBuffer , writeTarget , src , dimension , init , baseKernelName ) ; } } return writeTarget ; }
Runs the reduce index op.
Runs the reduce index op .
None
resultIndices
NDArray
The result indices.
The result indices .
src
NDArray
None
dimension
int
None
init
Tuple<float, float>
None
baseKernelName
string
Name of the base kernel.
Name of the base kernel .