Пример #1
0
        public void Test()
        {
            IntPtr pInputDesc  = IntPtr.Zero;
            IntPtr pOutputDesc = IntPtr.Zero;
            IntPtr pFilterDesc = IntPtr.Zero;
            IntPtr pConvDesc   = IntPtr.Zero;

            cudnnDataType dataType = cudnnDataType.CUDNN_DATA_FLOAT;
            int           n_in     = 64;  // Number of images - originally 128
            int           c_in     = 96;  // Number of feature maps per image - originally 96
            int           h_in     = 221; // Height of each feature map - originally 221
            int           w_in     = 221; // Width of each feature map - originally 221

            cuDNN6 dnn = new cuDNN6();

            pInputDesc  = dnn.CreateTensorDescriptor();
            pOutputDesc = dnn.CreateTensorDescriptor();
            pFilterDesc = dnn.CreateFilterDescriptor();
            pConvDesc   = dnn.CreateConvolutionDescriptor();

            dnn.SetTensor4dDescriptor(pInputDesc, cudnnTensorFormat.CUDNN_TENSOR_NCHW, dataType, n_in, c_in, h_in, w_in);
            //dnn.Getten

            Console.WriteLine(pInputDesc);
            dnn.DestroyConvolutionDescriptor(pConvDesc);
            dnn.DestroyFilterDescriptor(pFilterDesc);
            dnn.DestroyTensorDescriptor(pOutputDesc);
            dnn.DestroyTensorDescriptor(pInputDesc);
        }
Пример #2
0
 /// <summary>
 ///
 /// </summary>
 public void GetCTCLossDescriptorEx(ref cudnnDataType compType, ref cudnnLossNormalizationMode normMode, ref cudnnNanPropagation gradMode)
 {
     res = CudaDNNNativeMethods.cudnnGetCTCLossDescriptorEx(_desc, ref compType, ref normMode, ref gradMode);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetCTCLossDescriptorEx", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #3
0
 /// <summary>
 /// This function initializes a previously created CTC Loss descriptor object.
 /// </summary>
 /// <param name="dataType">Math precision.</param>
 public void SetCTCLossDescriptor(cudnnDataType dataType)
 {
     res = CudaDNNNativeMethods.cudnnSetCTCLossDescriptor(_desc, dataType);
     Debug.Write("");//Line(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetCTCLossDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
 /// <summary>
 /// </summary>
 public PersistentRNNPlan(RNNDescriptor rnnDesc, int minibatch, cudnnDataType dataType)
 {
     _desc = new cudnnPersistentRNNPlan();
     res   = CudaDNNNativeMethods.cudnnCreatePersistentRNNPlan(rnnDesc.Desc, minibatch, dataType, ref _desc);
     Debug.Write("");//Line(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnCreatePersistentRNNPlan", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #5
0
 public void SetFilterNdDescriptor(cudnnDataType dataType,         // image data type
                                   int nbDims,
                                   int[] filterDimA
                                   )
 {
     res = CudaDNNNativeMethods.cudnnSetFilterNdDescriptor(_desc, dataType, nbDims, filterDimA);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetFilterNdDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #6
0
        /// <summary>
        ///
        /// </summary>
        public cudnnDataType GetCTCLossDescriptor()
        {
            cudnnDataType dataType = new cudnnDataType();

            res = CudaDNNNativeMethods.cudnnGetCTCLossDescriptor(_desc, ref dataType);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetCTCLossDescriptor", res));
            if (res != cudnnStatus.Success)
            {
                throw new CudaDNNException(res);
            }
            return(dataType);
        }
Пример #7
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="opTensorOp"></param>
 /// <param name="opTensorCompType"></param>
 /// <param name="opTensorNanOpt"></param>
 public void GetOpTensorDescriptor(
     ref cudnnOpTensorOp opTensorOp,
     ref cudnnDataType opTensorCompType,
     ref cudnnNanPropagation opTensorNanOpt)
 {
     res = CudaDNNNativeMethods.cudnnGetOpTensorDescriptor(_desc, ref opTensorOp, ref opTensorCompType, ref opTensorNanOpt);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetOpTensorDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #8
0
 public void GetSeqDataDescriptor(ref cudnnDataType dataType, ref int nbDims,
                                  int[] dimA, cudnnSeqDataAxis[] axes,
                                  ref SizeT seqLengthArraySize, int[] seqLengthArray, IntPtr paddingFill)
 {
     res = CudaDNNNativeMethods.cudnnGetSeqDataDescriptor(_desc, ref dataType, ref nbDims,
                                                          dimA.Length, dimA, axes,
                                                          ref seqLengthArraySize, dimA.Length, seqLengthArray, paddingFill);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetSeqDataDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #9
0
 public void SetSeqDataDescriptor(cudnnDataType dataType, int nbDims,
                                  int[] dimA, cudnnSeqDataAxis[] axes,
                                  int[] seqLengthArray, float paddingFill)
 {
     res = CudaDNNNativeMethods.cudnnSetSeqDataDescriptor(_desc, dataType, nbDims,
                                                          dimA, axes,
                                                          seqLengthArray.Length, seqLengthArray, ref paddingFill);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetSeqDataDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #10
0
 /// <summary>
 /// This function destroys a previously created spatial transformer descriptor object.
 /// </summary>
 /// <param name="samplerType">Enumerant to specify the sampler type.</param>
 /// <param name="dataType">Data type.</param>
 /// <param name="nbDims">Dimension of the transformed tensor.</param>
 /// <param name="dimA">Array of dimension nbDims containing the size of the transformed tensor for every dimension.</param>
 public void SetSpatialTransformerNdDescriptor(
     cudnnSamplerType samplerType,
     cudnnDataType dataType,
     int nbDims,
     int[] dimA)
 {
     res = CudaDNNNativeMethods.cudnnSetSpatialTransformerNdDescriptor(_desc, samplerType, dataType, nbDims, dimA);
     Debug.Write("");//Line(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetSpatialTransformerNdDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #11
0
 /// <summary>
 ///
 /// </summary>
 public void SetRNNDataDescriptor(cudnnDataType dataType,
                                  cudnnRNNDataLayout layout, int maxSeqLength, int batchSize,
                                  int vectorSize,
                                  int[] seqLengthArray, /* length of each sequence in the batch */
                                  IntPtr paddingFill)
 {
     res = CudaDNNNativeMethods.cudnnSetRNNDataDescriptor(_desc, dataType,
                                                          layout, maxSeqLength, batchSize, vectorSize, seqLengthArray, paddingFill);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetRNNDataDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #12
0
 /// <summary>
 /// This function initializes a previously created generic Tensor descriptor object.
 /// </summary>
 /// <param name="tensorDesc">Handle to a previously created tensor descriptor.</param>
 /// <param name="format"></param>
 /// <param name="dataType">Data type.</param>
 /// <param name="nbDims">Dimension of the tensor.</param>
 /// <param name="dimA">Array of dimension nbDims that contain the size of the tensor for every dimension.</param>
 public void SetTensorNdDescriptorEx(
     cudnnTensorDescriptor tensorDesc,
     cudnnTensorFormat format,
     cudnnDataType dataType,
     int nbDims,
     int[] dimA)
 {
     res = CudaDNNNativeMethods.cudnnSetTensorNdDescriptorEx(_desc, format, dataType, nbDims, dimA);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetTensorNdDescriptorEx", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #13
0
 /// <summary>
 /// This function queries a previously initialized filter descriptor object.
 /// </summary>
 /// <param name="nbDimsRequested">Dimension of the expected filter descriptor. It is also the minimum size of
 /// the arrays filterDimA in order to be able to hold the results</param>
 /// <param name="dataType">Data type.</param>
 /// <param name="format">Enumerant holding the layout format.</param>
 /// <param name="nbDims">Actual dimension of the filter.</param>
 /// <param name="filterDimA">Array of dimension of at least nbDimsRequested that will be filled with
 /// the filter parameters from the provided filter descriptor.</param>
 public void GetFilterNdDescriptor(int nbDimsRequested,
                                   ref cudnnDataType dataType,                                               // image data type
                                   ref cudnnTensorFormat format,
                                   ref int nbDims,
                                   int[] filterDimA
                                   )
 {
     res = CudaDNNNativeMethods.cudnnGetFilterNdDescriptor(_desc, nbDimsRequested, ref dataType, ref format, ref nbDims, filterDimA);
     Debug.Write("");            //Line(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetFilterNdDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #14
0
 public void SetFilter4dDescriptor(cudnnDataType dataType,         // image data type
                                   int k,                          // number of output feature maps
                                   int c,                          // number of input feature maps
                                   int h,                          // height of each input filter
                                   int w                           // width of  each input fitler
                                   )
 {
     res = CudaDNNNativeMethods.cudnnSetFilter4dDescriptor(_desc, dataType, k, c, h, w);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetFilter4dDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #15
0
 /// <summary>
 /// This function initializes a previously created generic convolution descriptor object into
 /// a n-D correlation. That same convolution descriptor can be reused in the backward path
 /// provided it corresponds to the same layer. The convolution computation will done in the
 /// specified dataType, which can be potentially different from the input/output tensors.
 /// </summary>
 /// <param name="arrayLength">Dimension of the convolution.</param>
 /// <param name="padA">Array of dimension arrayLength containing the zero-padding size
 /// for each dimension. For every dimension, the padding represents the
 /// number of extra zeros implicitly concatenated at the start and at the
 /// end of every element of that dimension.</param>
 /// <param name="filterStrideA">Array of dimension arrayLength containing the filter stride for each
 /// dimension. For every dimension, the fitler stride represents the number
 /// of elements to slide to reach the next start of the filtering window of
 /// the next point.</param>
 /// <param name="dilationA">Array of dimension arrayLength containing the dilation factor for each dimension.</param>
 /// <param name="mode">Selects between CUDNN_CONVOLUTION and CUDNN_CROSS_CORRELATION.</param>
 /// <param name="computeType">Selects the datatype in which the computation will be done.</param>
 public void SetConvolutionNdDescriptor(int arrayLength,             /* nbDims-2 size */
                                        int[] padA,
                                        int[] filterStrideA,
                                        int[] dilationA,
                                        cudnnConvolutionMode mode, cudnnDataType computeType
                                        )
 {
     res = CudaDNNNativeMethods.cudnnSetConvolutionNdDescriptor(_desc, arrayLength, padA, filterStrideA, dilationA, mode, computeType);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetConvolutionNdDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #16
0
 /// <summary>
 /// This function retrieves values stored in a previously initialized Tensor descriptor object.
 /// </summary>
 /// <param name="nbDimsRequested">Number of dimensions to extract from a given tensor descriptor. It is
 /// also the minimum size of the arrays dimA and strideA. If this number is
 /// greater than the resulting nbDims[0], only nbDims[0] dimensions will be
 /// returned.</param>
 /// <param name="dataType">Data type.</param>
 /// <param name="nbDims">Actual number of dimensions of the tensor will be returned in nbDims[0].</param>
 /// <param name="dimA">Array of dimension of at least nbDimsRequested that will be filled with
 /// the dimensions from the provided tensor descriptor.</param>
 /// <param name="strideA">Array of dimension of at least nbDimsRequested that will be filled with
 /// the strides from the provided tensor descriptor.</param>
 public void GetTensorNdDescriptor(int nbDimsRequested,
                                   ref cudnnDataType dataType,
                                   ref int nbDims,
                                   int[] dimA,
                                   int[] strideA
                                   )
 {
     res = CudaDNNNativeMethods.cudnnGetTensorNdDescriptor(_desc, nbDimsRequested, ref dataType, ref nbDims, dimA, strideA);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetTensorNdDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #17
0
 /// <summary>
 ///
 /// </summary>
 public void GetRNNDataDescriptor(ref cudnnDataType dataType,
                                  ref cudnnRNNDataLayout layout, ref int maxSeqLength, ref int batchSize,
                                  ref int vectorSize, int arrayLengthRequested, int[] seqLengthArray,
                                  IntPtr paddingFill)
 {
     res = CudaDNNNativeMethods.cudnnGetRNNDataDescriptor(_desc, ref dataType,
                                                          ref layout, ref maxSeqLength, ref batchSize,
                                                          ref vectorSize, arrayLengthRequested, seqLengthArray,
                                                          paddingFill);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetRNNDataDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #18
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="reduceTensorOp"></param>
 /// <param name="reduceTensorCompType"></param>
 /// <param name="reduceTensorNanOpt"></param>
 /// <param name="reduceTensorIndices"></param>
 /// <param name="reduceTensorIndicesType"></param>
 public void GetReduceTensorDescriptor(
     ref cudnnReduceTensorOp reduceTensorOp,
     ref cudnnDataType reduceTensorCompType,
     ref cudnnNanPropagation reduceTensorNanOpt,
     ref cudnnReduceTensorIndices reduceTensorIndices,
     ref cudnnIndicesType reduceTensorIndicesType)
 {
     res = CudaDNNNativeMethods.cudnnGetReduceTensorDescriptor(_desc, ref reduceTensorOp, ref reduceTensorCompType,
                                                               ref reduceTensorNanOpt, ref reduceTensorIndices, ref reduceTensorIndicesType);
     Debug.Write("");//Line(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetReduceTensorDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #19
0
 /// <summary>
 /// This function queries a previously initialized convolution descriptor object.
 /// </summary>
 /// <param name="arrayLengthRequested">Dimension of the expected convolution descriptor. It is also the
 /// minimum size of the arrays padA, filterStrideA and upsacleA in
 /// order to be able to hold the results</param>
 /// <param name="arrayLength">actual dimension of the convolution descriptor.</param>
 /// <param name="padA">Array of dimension of at least arrayLengthRequested that will be
 /// filled with the padding parameters from the provided convolution
 /// descriptor.</param>
 /// <param name="strideA">Array of dimension of at least arrayLengthRequested that will be
 /// filled with the filter stride from the provided convolution descriptor.</param>
 /// <param name="dilationA">Array of dimension at least arrayLengthRequested that will be filled
 /// with the dilation parameters from the provided convolution descriptor.</param>
 /// <param name="mode">convolution mode of the provided descriptor.</param>
 /// <param name="computeType">datatype of the provided descriptor.</param>
 public void GetConvolutionNdDescriptor(int arrayLengthRequested,
                                        ref int arrayLength,
                                        int[] padA,
                                        int[] strideA,
                                        int[] dilationA,
                                        ref cudnnConvolutionMode mode, ref cudnnDataType computeType
                                        )
 {
     res = CudaDNNNativeMethods.cudnnGetConvolutionNdDescriptor(_desc, arrayLengthRequested, ref arrayLength, padA, strideA, dilationA, ref mode, ref computeType);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetConvolutionNdDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #20
0
 /// <summary>
 /// This function initializes a previously created generic Tensor descriptor object into a
 /// 4D tensor. The strides of the four dimensions are inferred from the format parameter
 /// and set in such a way that the data is contiguous in memory with no padding between
 /// dimensions.
 /// </summary>
 /// <param name="format">Type of format.</param>
 /// <param name="dataType">Data type.</param>
 /// <param name="n">Number of images.</param>
 /// <param name="c">Number of feature maps per image.</param>
 /// <param name="h">Height of each feature map.</param>
 /// <param name="w">Width of each feature map.</param>
 public void SetTensor4dDescriptor(cudnnTensorFormat format,
                                   cudnnDataType dataType, // image data type
                                   int n,                  // number of inputs (batch size)
                                   int c,                  // number of input feature maps
                                   int h,                  // height of input section
                                   int w                   // width of input section
                                   )
 {
     res = CudaDNNNativeMethods.cudnnSetTensor4dDescriptor(_desc, format, dataType, n, c, h, w);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetTensor4dDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #21
0
 /// <summary>
 /// This function queries the parameters of the previouly initialized filter descriptor object.
 /// </summary>
 /// <param name="dataType">Data type.</param>
 /// <param name="format">Enumerant holding the layout format.</param>
 /// <param name="k">Number of output feature maps.</param>
 /// <param name="c">Number of input feature maps.</param>
 /// <param name="h">Height of each filter.</param>
 /// <param name="w">Width of each filter.</param>
 public void GetFilter4dDescriptor(ref cudnnDataType dataType,         // image data type
                                   ref cudnnTensorFormat format,
                                   ref int k,                          // number of output feature maps
                                   ref int c,                          // number of input feature maps
                                   ref int h,                          // height of each input filter
                                   ref int w                           // width of  each input fitler
                                   )
 {
     res = CudaDNNNativeMethods.cudnnGetFilter4dDescriptor(_desc, ref dataType, ref format, ref k, ref c, ref h, ref w);
     Debug.Write("");            //Line(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetFilter4dDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #22
0
 /// <summary>
 /// This function initializes a previously created convolution descriptor object into a 2D
 /// correlation. This function assumes that the tensor and filter descriptors corresponds
 /// to the formard convolution path and checks if their settings are valid. That same
 /// convolution descriptor can be reused in the backward path provided it corresponds to
 /// the same layer.
 /// </summary>
 /// <param name="pad_h">zero-padding height: number of rows of zeros implicitly concatenated
 /// onto the top and onto the bottom of input images.</param>
 /// <param name="pad_w">zero-padding width: number of columns of zeros implicitly concatenated
 /// onto the left and onto the right of input images.</param>
 /// <param name="u">Vertical filter stride.</param>
 /// <param name="v">Horizontal filter stride.</param>
 /// <param name="upscalex">Upscale the input in x-direction.</param>
 /// <param name="upscaley">Upscale the input in y-direction.</param>
 /// <param name="mode">Selects between CUDNN_CONVOLUTION and CUDNN_CROSS_CORRELATION.</param>
 /// <param name="dataType">Selects the datatype in which the computation will be done.</param>
 public void SetConvolution2dDescriptor(int pad_h,            // zero-padding height
                                        int pad_w,            // zero-padding width
                                        int u,                // vertical filter stride
                                        int v,                // horizontal filter stride
                                        int upscalex,         // upscale the input in x-direction
                                        int upscaley,         // upscale the input in y-direction
                                        cudnnConvolutionMode mode,
                                        cudnnDataType dataType
                                        )
 {
     res = CudaDNNNativeMethods.cudnnSetConvolution2dDescriptor(_desc, pad_h, pad_w, u, v, upscalex, upscaley, mode, dataType);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetConvolution2dDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #23
0
 /// <summary>
 /// This function queries a previously initialized 2D convolution descriptor object.
 /// </summary>
 /// <param name="pad_h">zero-padding height: number of rows of zeros implicitly concatenated
 /// onto the top and onto the bottom of input images.</param>
 /// <param name="pad_w">zero-padding width: number of columns of zeros implicitly concatenated
 /// onto the left and onto the right of input images.</param>
 /// <param name="u">Vertical filter stride.</param>
 /// <param name="v">Horizontal filter stride.</param>
 /// <param name="dilation_h">Filter height dilation.</param>
 /// <param name="dilation_w">Filter width dilation.</param>
 /// <param name="mode">convolution mode.</param>
 /// <param name="dataType">Selects the datatype in which the computation will be done.</param>
 public void GetConvolution2dDescriptor(ref int pad_h,      // zero-padding height
                                        ref int pad_w,      // zero-padding width
                                        ref int u,          // vertical filter stride
                                        ref int v,          // horizontal filter stride
                                        ref int dilation_h, // filter dilation in the vertical dimension
                                        ref int dilation_w, // filter dilation in the horizontal dimension
                                        ref cudnnConvolutionMode mode,
                                        ref cudnnDataType dataType
                                        )
 {
     res = CudaDNNNativeMethods.cudnnGetConvolution2dDescriptor(_desc, ref pad_h, ref pad_w, ref u, ref v, ref dilation_h, ref dilation_w, ref mode, ref dataType);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetConvolution2dDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #24
0
 /// <summary>
 /// This function queries the parameters of the previouly initialized Tensor4D descriptor object.
 /// </summary>
 /// <param name="dataType">Data type.</param>
 /// <param name="n">Number of images.</param>
 /// <param name="c">Number of feature maps per image.</param>
 /// <param name="h">Height of each feature map.</param>
 /// <param name="w">Width of each feature map.</param>
 /// <param name="nStride">Stride between two consecutive images.</param>
 /// <param name="cStride">Stride between two consecutive feature maps.</param>
 /// <param name="hStride">Stride between two consecutive rows.</param>
 /// <param name="wStride">Stride between two consecutive columns.</param>
 public void GetTensor4dDescriptor(ref cudnnDataType dataType, // image data type
                                   ref int n,                  // number of inputs (batch size)
                                   ref int c,                  // number of input feature maps
                                   ref int h,                  // height of input section
                                   ref int w,                  // width of input section
                                   ref int nStride,
                                   ref int cStride,
                                   ref int hStride,
                                   ref int wStride
                                   )
 {
     res = CudaDNNNativeMethods.cudnnGetTensor4dDescriptor(_desc, ref dataType, ref n, ref c, ref h, ref w, ref nStride, ref cStride, ref hStride, ref wStride);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetTensor4dDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #25
0
 public void SetAttnDescriptor(uint attnMode, int nHeads,
                               double smScaler, cudnnDataType dataType, cudnnDataType computePrec,
                               cudnnMathType mathType, DropoutDescriptor attnDropoutDesc,
                               DropoutDescriptor postDropoutDesc, int qSize, int kSize, int vSize,
                               int qProjSize, int kProjSize, int vProjSize, int oProjSize,
                               int qoMaxSeqLength, int kvMaxSeqLength, int maxBatchSize, int maxBeamSize)
 {
     res = CudaDNNNativeMethods.cudnnSetAttnDescriptor(_desc, attnMode, nHeads,
                                                       smScaler, dataType, computePrec,
                                                       mathType, attnDropoutDesc.Desc,
                                                       postDropoutDesc.Desc, qSize, kSize, vSize,
                                                       qProjSize, kProjSize, vProjSize, oProjSize,
                                                       qoMaxSeqLength, kvMaxSeqLength, maxBatchSize, maxBeamSize);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetAttnDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Пример #26
0
		public static extern cudnnStatus cudnnGetFilter4dDescriptor(  cudnnFilterDescriptor filterDesc,
															   ref cudnnDataType dataType, // image data type
															   ref int k,        // number of output feature maps
															   ref int c,        // number of input feature maps
															   ref int h,        // height of each input filter
															   ref int w         // width of  each input fitler
														  );
Пример #27
0
 public static extern cudnnStatus cudnnSetFilter4dDescriptor(cudnnFilterDescriptor filterDesc,
                                                        cudnnDataType dataType, // image data type
                                                        cudnnTensorFormat format, // layout format
                                                        int k,        // number of output feature maps
                                                        int c,        // number of input feature maps
                                                        int h,        // height of each input filter
                                                        int w         // width of  each input fitler
                                                   );
Пример #28
0
 public static extern cudnnStatus cudnnSetRNNDescriptor(cudnnRNNDescriptor rnnDesc,
                                                 int hiddenSize,
                                                 int seqLength,
                                                 int numLayers,
                                                 cudnnDropoutDescriptor dropoutDesc, // Between layers, not between recurrent steps.
                                                 cudnnRNNInputMode inputMode,
                                                 cudnnDirectionMode direction,
                                                 cudnnRNNMode mode,
                                                 cudnnDataType dataType);
Пример #29
0
		public static extern cudnnStatus cudnnSetTensorNdDescriptor(cudnnTensorDescriptor tensorDesc,
															   cudnnDataType dataType,
															   int nbDims,
															   int[] dimA,
															   int[] strideA
															 );
Пример #30
0
 /// <summary>
 /// This function initializes a previously created generic Tensor descriptor object into a
 /// 4D tensor, similarly to cudnnSetTensor4dDescriptor but with the strides explicitly
 /// passed as parameters. This can be used to lay out the 4D tensor in any order or simply to
 /// define gaps between dimensions.
 /// </summary>
 /// <param name="dataType">Data type.</param>
 /// <param name="n">Number of images.</param>
 /// <param name="c">Number of feature maps per image.</param>
 /// <param name="h">Height of each feature map.</param>
 /// <param name="w">Width of each feature map.</param>
 /// <param name="nStride">Stride between two consecutive images.</param>
 /// <param name="cStride">Stride between two consecutive feature maps.</param>
 /// <param name="hStride">Stride between two consecutive rows.</param>
 /// <param name="wStride">Stride between two consecutive columns.</param>
 public void SetTensor4dDescriptorEx(cudnnDataType dataType, // image data type
                                     int n,        // number of inputs (batch size)
                                     int c,        // number of input feature maps
                                     int h,        // height of input section
                                     int w,        // width of input section
                                     int nStride,
                                     int cStride,
                                     int hStride,
                                     int wStride
                                     )
 {
     res = CudaDNNNativeMethods.cudnnSetTensor4dDescriptorEx(_desc, dataType, n, c, h, w, nStride, cStride, hStride, wStride);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetTensor4dDescriptorEx", res));
     if (res != cudnnStatus.Success) throw new CudaDNNException(res);
 }
Пример #31
0
		public static extern cudnnStatus cudnnSetConvolutionNdDescriptor(cudnnConvolutionDescriptor convDesc,
                                                              int arrayLength,             /* nbDims-2 size */  
                                                              int[] padA,                                          
                                                              int[] filterStrideA,         
                                                              int[] upscaleA,              
                                                              cudnnConvolutionMode mode,
                                                              cudnnDataType dataType   // convolution data type
                                                         );
Пример #32
0
 public static extern cudnnStatus cudnnSetOpTensorDescriptor(
                                 cudnnOpTensorDescriptor opTensorDesc,
                                 cudnnOpTensorOp opTensorOp,
                                 cudnnDataType opTensorCompType,
                                 cudnnNanPropagation opTensorNanOpt);
Пример #33
0
		public static extern cudnnStatus cudnnGetConvolutionNdDescriptor(cudnnConvolutionDescriptor convDesc,
                                                              int arrayLengthRequested,
                                                              ref int arrayLength,
                                                              int[] padA,                                        
                                                              int[] strideA,
                                                              int[] upscaleA,
                                                              ref cudnnConvolutionMode mode,
                                                              ref cudnnDataType dataType     // convolution data type
                                                         );
Пример #34
0
        /// <summary>
        /// This function initializes a previously created generic convolution descriptor object into
        /// a n-D correlation. That same convolution descriptor can be reused in the backward path
        /// provided it corresponds to the same layer. The convolution computation will done in the
        /// specified dataType, which can be potentially different from the input/output tensors.
        /// </summary>
        /// <param name="arrayLength">Dimension of the convolution.</param>
        /// <param name="padA">Array of dimension arrayLength containing the zero-padding size
        /// for each dimension. For every dimension, the padding represents the
        /// number of extra zeros implicitly concatenated at the start and at the
        /// end of every element of that dimension.</param>
        /// <param name="filterStrideA">Array of dimension arrayLength containing the filter stride for each
        /// dimension. For every dimension, the fitler stride represents the number
        /// of elements to slide to reach the next start of the filtering window of
        /// the next point.</param>
        /// <param name="upscaleA">Array of dimension arrayLength containing the upscale factor for each dimension.</param>
        /// <param name="mode">Selects between CUDNN_CONVOLUTION and CUDNN_CROSS_CORRELATION.</param>
        /// <param name="dataType">Selects the datatype in which the computation will be done.</param>
        public void SetConvolutionNdDescriptor(int arrayLength,             /* nbDims-2 size */
											int[] padA,
											int[] filterStrideA,
											int[] upscaleA,
											cudnnConvolutionMode mode, cudnnDataType dataType
											)
        {
            res = CudaDNNNativeMethods.cudnnSetConvolutionNdDescriptor(_desc, arrayLength, padA, filterStrideA, upscaleA, mode, dataType);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetConvolutionNdDescriptor", res));
            if (res != cudnnStatus.Success) throw new CudaDNNException(res);
        }
Пример #35
0
        public static extern cudnnStatus cudnnSetConvolution2dDescriptor(  cudnnConvolutionDescriptor convDesc,
																	int pad_h,    // zero-padding height
																	int pad_w,    // zero-padding width
																	int u,        // vertical filter stride
																	int v,        // horizontal filter stride
																	int upscalex, // upscale the input in x-direction
																	int upscaley, // upscale the input in y-direction
																	cudnnConvolutionMode mode,
                                                                    cudnnDataType dataType
                                                                 );
Пример #36
0
        /// <summary>
        /// This function queries a previously initialized convolution descriptor object.
        /// </summary>
        /// <param name="arrayLengthRequested">Dimension of the expected convolution descriptor. It is also the
        /// minimum size of the arrays padA, filterStrideA and upsacleA in
        /// order to be able to hold the results</param>
        /// <param name="arrayLength">actual dimension of the convolution descriptor.</param>
        /// <param name="padA">Array of dimension of at least arrayLengthRequested that will be
        /// filled with the padding parameters from the provided convolution
        /// descriptor.</param>
        /// <param name="strideA">Array of dimension of at least arrayLengthRequested that will be
        /// filled with the filter stride from the provided convolution descriptor.</param>
        /// <param name="upscaleA">Array of dimension at least arrayLengthRequested that will be filled
        /// with the upscaling parameters from the provided convolution descriptor.</param>
        /// <param name="mode">convolution mode of the provided descriptor.</param>
        /// <param name="dataType">datatype of the provided descriptor.</param>
        public void GetConvolutionNdDescriptor(int arrayLengthRequested,
											ref int arrayLength,
											int[] padA,
											int[] strideA,
											int[] upscaleA,
											ref cudnnConvolutionMode mode, ref cudnnDataType dataType
											)
        {
            res = CudaDNNNativeMethods.cudnnGetConvolutionNdDescriptor(_desc, arrayLengthRequested, ref arrayLength, padA, strideA, upscaleA, ref  mode, ref dataType);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetConvolutionNdDescriptor", res));
            if (res != cudnnStatus.Success) throw new CudaDNNException(res);
        }
Пример #37
0
		public static extern cudnnStatus cudnnSetTensor4dDescriptor(cudnnTensorDescriptor tensorDesc,
																cudnnTensorFormat  format,
																cudnnDataType dataType, // image data type
																int n,        // number of inputs (batch size)
																int c,        // number of input feature maps
																int h,        // height of input section
																int w         // width of input section
															);
Пример #38
0
 /// <summary>
 /// This function queries the parameters of the previouly initialized Tensor4D descriptor object.
 /// </summary>
 /// <param name="dataType">Data type.</param>
 /// <param name="n">Number of images.</param>
 /// <param name="c">Number of feature maps per image.</param>
 /// <param name="h">Height of each feature map.</param>
 /// <param name="w">Width of each feature map.</param>
 /// <param name="nStride">Stride between two consecutive images.</param>
 /// <param name="cStride">Stride between two consecutive feature maps.</param>
 /// <param name="hStride">Stride between two consecutive rows.</param>
 /// <param name="wStride">Stride between two consecutive columns.</param>
 public void GetTensor4dDescriptor(ref cudnnDataType dataType, // image data type
                                     ref int n,        // number of inputs (batch size)
                                     ref int c,        // number of input feature maps
                                     ref int h,        // height of input section
                                     ref int w,        // width of input section
                                     ref int nStride,
                                     ref int cStride,
                                     ref int hStride,
                                     ref int wStride
                                 )
 {
     res = CudaDNNNativeMethods.cudnnGetTensor4dDescriptor(_desc, ref dataType, ref n, ref c, ref h, ref w, ref nStride, ref cStride, ref hStride, ref wStride);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetTensor4dDescriptor", res));
     if (res != cudnnStatus.Success) throw new CudaDNNException(res);
 }
Пример #39
0
		public static extern cudnnStatus cudnnGetFilterNdDescriptor(  cudnnFilterDescriptor filterDesc,
															   int nbDimsRequested,
															   ref cudnnDataType dataType, // image data type
															   ref int nbDims,
															   int[] filterDimA
															);
Пример #40
0
 /// <summary>
 /// This function initializes a previously created generic Tensor descriptor object.
 /// </summary>
 /// <param name="dataType">Data type.</param>
 /// <param name="nbDims">Dimension of the tensor.</param>
 /// <param name="dimA">Array of dimension nbDims that contain the size of the tensor for every dimension.</param>
 /// <param name="strideA">Array of dimension nbDims that contain the stride of the tensor for every dimension.</param>
 public void SetTensorNdDescriptor(cudnnDataType dataType,
                                     int nbDims,
                                     int[] dimA,
                                     int[] strideA
                                     )
 {
     res = CudaDNNNativeMethods.cudnnSetTensorNdDescriptor(_desc, dataType, nbDims, dimA, strideA);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetTensorNdDescriptor", res));
     if (res != cudnnStatus.Success) throw new CudaDNNException(res);
 }
Пример #41
0
		public static extern cudnnStatus cudnnSetFilterNdDescriptor(  cudnnFilterDescriptor filterDesc,
															   cudnnDataType dataType, // image data type
															   int nbDims,
															   int[] filterDimA
															 );
Пример #42
0
		public static extern cudnnStatus cudnnGetTensorNdDescriptor(  cudnnTensorDescriptor tensorDesc,
															   int nbDimsRequested,
															   ref cudnnDataType dataType,
															   ref int nbDims,
															   int[] dimA,
															   int[] strideA
															 );
Пример #43
0
        /// <summary>
        /// This function initializes a previously created filter descriptor object into a 4D filter.
        /// Filters layout must be contiguous in memory.
        /// </summary>
        /// <param name="dataType">Data type.</param>
        /// <param name="format">Enumerant holding the layout format.</param>
        /// <param name="k">Number of output feature maps.</param>
        /// <param name="c">Number of input feature maps.</param>
        /// <param name="h">Height of each filter.</param>
        /// <param name="w">Width of each filter.</param>
        public void SetFilter4dDescriptor(cudnnDataType dataType, // image data type
                                                cudnnTensorFormat format,
												int k,        // number of output feature maps
												int c,        // number of input feature maps
												int h,        // height of each input filter
												int w         // width of  each input fitler
											)
        {
            res = CudaDNNNativeMethods.cudnnSetFilter4dDescriptor(_desc, dataType, format, k, c, h, w);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetFilter4dDescriptor", res));
            if (res != cudnnStatus.Success) throw new CudaDNNException(res);
        }
Пример #44
0
 public static extern cudnnStatus cudnnSetSpatialTransformerNdDescriptor(
                                 cudnnSpatialTransformerDescriptor stDesc,
                                 cudnnSamplerType samplerType,
                                 cudnnDataType dataType,
                                 int nbDims,
                                 int []dimA);
Пример #45
0
        /// <summary>
        /// This function initializes a previously created filter descriptor object. Filters layout must
        /// be contiguous in memory.
        /// </summary>
        /// <param name="dataType">Data type.</param>
        /// <param name="format">Enumerant holding the layout format.</param>
        /// <param name="nbDims">Dimension of the filter.</param>
        /// <param name="filterDimA">Array of dimension nbDims containing the size of the filter for each dimension.</param>
        public void SetFilterNdDescriptor(cudnnDataType dataType, // image data type
                                            cudnnTensorFormat format,
											int nbDims,
											int[] filterDimA
											)
        {
            res = CudaDNNNativeMethods.cudnnSetFilterNdDescriptor(_desc, dataType, format, nbDims, filterDimA);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetFilterNdDescriptor", res));
            if (res != cudnnStatus.Success) throw new CudaDNNException(res);
        }
Пример #46
0
		public static extern cudnnStatus cudnnGetTensor4dDescriptor(   cudnnTensorDescriptor tensorDesc,
																ref cudnnDataType dataType, // image data type
																ref int n,        // number of inputs (batch size)
																ref int c,        // number of input feature maps
																ref int h,        // height of input section
																ref int w,        // width of input section
																ref int nStride,
																ref int cStride,
																ref int hStride,
																ref int wStride
															);
Пример #47
0
 /// <summary>
 /// This function initializes a previously created RNN descriptor object.
 /// </summary>
 /// <param name="hiddenSize">Size of the internal hidden state for each layer.</param>
 /// <param name="seqLength">Number of iterations to unroll over.</param>
 /// <param name="numLayers">Number of layers.</param>
 /// <param name="dropoutDesc">Handle to a previously created and initialized dropout descriptor.</param>
 /// <param name="inputMode">Specifies the behavior at the input to the first layer.</param>
 /// <param name="direction">Specifies the recurrence pattern. (eg. bidirectional)</param>
 /// <param name="mode">The type of RNN to compute.</param>
 /// <param name="dataType">Math precision.</param>
 public void SetRNNDescriptor(
                                                 int hiddenSize,
                                                 int seqLength,
                                                 int numLayers,
                                                 DropoutDescriptor dropoutDesc, // Between layers, not between recurrent steps.
                                                 cudnnRNNInputMode inputMode,
                                                 cudnnDirectionMode direction,
                                                 cudnnRNNMode mode,
                                                 cudnnDataType dataType)
 {
     res = CudaDNNNativeMethods.cudnnSetRNNDescriptor(_desc, hiddenSize, seqLength, numLayers, dropoutDesc.Desc, inputMode, direction, mode, dataType);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetRNNDescriptor", res));
     if (res != cudnnStatus.Success) throw new CudaDNNException(res);
 }
Пример #48
0
        public void GetFilterNdDescriptor(int nbDimsRequested,
											ref cudnnDataType dataType, // image data type
											ref int nbDims,
											int[] filterDimA
										)
        {
            res = CudaDNNNativeMethods.cudnnGetFilterNdDescriptor(_desc, nbDimsRequested, ref dataType, ref nbDims, filterDimA);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetFilterNdDescriptor", res));
            if (res != cudnnStatus.Success) throw new CudaDNNException(res);
        }
Пример #49
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="opTensorOp"></param>
 /// <param name="opTensorCompType"></param>
 /// <param name="opTensorNanOpt"></param>
 public void GetOpTensorDescriptor(
                                 ref cudnnOpTensorOp opTensorOp,
                                 ref cudnnDataType opTensorCompType,
                                 ref cudnnNanPropagation opTensorNanOpt)
 {
     res = CudaDNNNativeMethods.cudnnGetOpTensorDescriptor(_desc, ref opTensorOp, ref opTensorCompType, ref opTensorNanOpt);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetOpTensorDescriptor", res));
     if (res != cudnnStatus.Success) throw new CudaDNNException(res);
 }
Пример #50
0
        /// <summary>
        /// This function initializes a previously created convolution descriptor object into a 2D
        /// correlation. This function assumes that the tensor and filter descriptors corresponds
        /// to the formard convolution path and checks if their settings are valid. That same
        /// convolution descriptor can be reused in the backward path provided it corresponds to
        /// the same layer.
        /// </summary>
        /// <param name="pad_h">zero-padding height: number of rows of zeros implicitly concatenated
        /// onto the top and onto the bottom of input images.</param>
        /// <param name="pad_w">zero-padding width: number of columns of zeros implicitly concatenated
        /// onto the left and onto the right of input images.</param>
        /// <param name="u">Vertical filter stride.</param>
        /// <param name="v">Horizontal filter stride.</param>
        /// <param name="upscalex">Upscale the input in x-direction.</param>
        /// <param name="upscaley">Upscale the input in y-direction.</param>
        /// <param name="mode">Selects between CUDNN_CONVOLUTION and CUDNN_CROSS_CORRELATION.</param>
        /// <param name="dataType">Selects the datatype in which the computation will be done.</param>
        public void SetConvolution2dDescriptor(int pad_h,    // zero-padding height
												int pad_w,    // zero-padding width
												int u,        // vertical filter stride
												int v,        // horizontal filter stride
												int upscalex, // upscale the input in x-direction
												int upscaley, // upscale the input in y-direction
												cudnnConvolutionMode mode,
                                                cudnnDataType dataType
                                                )
        {
            res = CudaDNNNativeMethods.cudnnSetConvolution2dDescriptor(_desc, pad_h, pad_w, u, v, upscalex, upscaley, mode, dataType);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetConvolution2dDescriptor", res));
            if (res != cudnnStatus.Success) throw new CudaDNNException(res);
        }
Пример #51
0
 public static extern cudnnStatus cudnnSetFilterNdDescriptor(cudnnFilterDescriptor filterDesc,
                                                        cudnnDataType dataType, // image data type
                                                        cudnnTensorFormat format, // layout format
                                                        int nbDims,
                                                        int[] filterDimA
                                                      );