public void CopyAlgorithmDescriptor(AlgorithmDescriptor dest)
 {
     res = CudaDNNNativeMethods.cudnnCopyAlgorithmDescriptor(_desc, dest.Desc);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnCopyAlgorithmDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Esempio n. 2
0
 public void SetFusedOpsVariantParamPackAttribute(cudnnFusedOpsVariantParamLabel paramLabel, IntPtr param)
 {
     res = CudaDNNNativeMethods.cudnnSetFusedOpsVariantParamPackAttribute(_pack, paramLabel, param);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetFusedOpsVariantParamPackAttribute", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Esempio n. 3
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);
     }
 }
 public void SetAlgorithmPerformance(int index, AlgorithmDescriptor algoDesc, cudnnStatus status, float time, SizeT memory)
 {
     res = CudaDNNNativeMethods.cudnnSetAlgorithmPerformance(_perfs[index], algoDesc.Desc, status, time, memory);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetAlgorithmPerformance", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Esempio n. 5
0
 /// <summary>
 /// This function sets the stream to be used by the cudnn library to execute its routines.
 /// </summary>
 /// <param name="stream">the stream to be used by the library.</param>
 public void SetStream(CudaStream stream)
 {
     res = CudaDNNNativeMethods.cudnnSetStream(_handle, stream.Stream);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetStream", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Esempio n. 6
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);
     }
 }
Esempio n. 7
0
 /// <summary>
 /// </summary>
 public CudaDNNContext()
 {
     _handle = new cudnnHandle();
     res     = CudaDNNNativeMethods.cudnnCreate(ref _handle);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnCreate", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Esempio n. 8
0
 /// <summary>
 /// </summary>
 public FusedOpsVariantParamPack(cudnnFusedOps ops)
 {
     _pack = new cudnnFusedOpsVariantParamPack();
     res   = CudaDNNNativeMethods.cudnnCreateFusedOpsVariantParamPack(ref _pack, ops);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnCreateFusedOpsVariantParamPack", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Esempio n. 9
0
 /// <summary>
 /// </summary>
 public TensorDescriptor()
 {
     _desc = new cudnnTensorDescriptor();
     res   = CudaDNNNativeMethods.cudnnCreateTensorDescriptor(ref _desc);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnCreateTensorDescriptor", 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);
     }
 }
 /// <summary>
 /// </summary>
 public AlgorithmPerformances(int count)
 {
     _perfs = new cudnnAlgorithmPerformance[count];
     res    = CudaDNNNativeMethods.cudnnCreateAlgorithmPerformance(_perfs, count);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnCreateAlgorithmPerformance", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Esempio n. 12
0
 /// <summary>
 /// This function queries the parameters of the previouly initialized activation descriptor object.
 /// </summary>
 /// <param name="mode">Enumerant to specify the activation mode.</param>
 /// <param name="reluNanOpt">Nan propagation option for the relu.</param>
 /// <param name="reluCeiling">The ceiling for the clipped relu.</param>
 public void GetActivationDescriptor(ref cudnnActivationMode mode,
                                     ref cudnnNanPropagation reluNanOpt,
                                     ref double reluCeiling)
 {
     res = CudaDNNNativeMethods.cudnnGetActivationDescriptor(_desc, ref mode, ref reluNanOpt, ref reluCeiling);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetActivationDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Esempio n. 13
0
 /// <summary>
 /// This function provides the output dimensions of a tensor after Nd pooling has been applied
 /// </summary>
 /// <param name="inputTensorDesc">Handle to the previously initialized input tensor descriptor.</param>
 /// <param name="nbDims">Number of dimensions in which pooling is to be applied.</param>
 /// <param name="outputTensorDimA">Array of nbDims output dimensions</param>
 public void GetPoolingNdForwardOutputDim(TensorDescriptor inputTensorDesc,
                                          int nbDims,
                                          int[] outputTensorDimA)
 {
     res = CudaDNNNativeMethods.cudnnGetPoolingNdForwardOutputDim(_desc, inputTensorDesc.Desc, nbDims, outputTensorDimA);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetPoolingNdForwardOutputDim", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Esempio n. 14
0
 /// <summary>
 /// </summary>
 public LRNDescriptor(CudaDNNContext context)
 {
     _handle = context.Handle;
     _desc   = new cudnnLRNDescriptor();
     res     = CudaDNNNativeMethods.cudnnCreateLRNDescriptor(ref _desc);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnCreateLRNDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
 /// <summary>
 /// This function computes the gradient of a grid generation operation.
 /// </summary>
 /// <param name="dgrid">Data pointer to GPU memory contains the input differential data.</param>
 /// <param name="dtheta">Data pointer to GPU memory contains the output differential data.</param>
 /// <returns></returns>
 public void SpatialTfGridGeneratorBackward(
     CudaDeviceVariable <float> dgrid,
     CudaDeviceVariable <float> dtheta)
 {
     res = CudaDNNNativeMethods.cudnnSpatialTfGridGeneratorBackward(_handle, _desc, dtheta.DevicePointer, dgrid.DevicePointer);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSpatialTfGridGeneratorBackward", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Esempio n. 16
0
 ///<summary>
 /// This function initializes then previously created activation descriptor object.
 /// </summary>
 /// <param name="mode">Enumerant to specify the activation mode.</param>
 /// <param name="reluNanOpt">Nan propagation option for the relu.</param>
 /// <param name="coef">floating point number to specify the clipping threashold when the activation
 /// mode is set to CUDNN_ACTIVATION_CLIPPED_RELU or to specify the alpha
 /// coefficient when the activation mode is set to CUDNN_ACTIVATION_ELU.</param>
 public void SetActivationDescriptor(cudnnActivationMode mode,
                                     cudnnNanPropagation reluNanOpt,
                                     double coef)
 {
     res = CudaDNNNativeMethods.cudnnSetActivationDescriptor(_desc, mode, reluNanOpt, coef);
     Debug.Write("");//Line(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetActivationDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
        public cudnnAlgorithm GetAlgorithmDescriptor()
        {
            cudnnAlgorithm algo = new cudnnAlgorithm();

            res = CudaDNNNativeMethods.cudnnGetAlgorithmDescriptor(_desc, ref algo);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnSetAlgorithmDescriptor", res));
            if (res != cudnnStatus.Success)
            {
                throw new CudaDNNException(res);
            }
            return(algo);
        }
        public void GetAlgorithmPerformance(int index, ref AlgorithmDescriptor algoDesc, ref cudnnStatus status, ref float time, ref SizeT memory)
        {
            cudnnAlgorithmDescriptor descTemp = new cudnnAlgorithmDescriptor();

            res = CudaDNNNativeMethods.cudnnGetAlgorithmPerformance(_perfs[index], ref descTemp, ref status, ref time, ref memory);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetAlgorithmPerformance", res));
            if (res != cudnnStatus.Success)
            {
                throw new CudaDNNException(res);
            }
            algoDesc = new AlgorithmDescriptor(descTemp);
        }
Esempio n. 19
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);
     }
 }
Esempio n. 20
0
 /// <summary>
 /// Retrieves the values stored in a previously initialized tensor transform descriptor.
 /// </summary>
 public void GetTensorTransformDescriptor(uint nbDims,
                                          cudnnTensorFormat destFormat, int[] padBeforeA,
                                          int[] padAfterA, uint[] foldA,
                                          cudnnFoldingDirection direction)
 {
     res = CudaDNNNativeMethods.cudnnGetTensorTransformDescriptor(_desc, nbDims, ref destFormat, padBeforeA, padAfterA, foldA, ref direction);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetTensorTransformDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Esempio n. 21
0
        public SizeT InitTransformDest(TensorDescriptor srcDesc, TensorDescriptor destDesc)
        {
            SizeT destSizeInBytes = new SizeT();

            res = CudaDNNNativeMethods.cudnnInitTransformDest(_desc, srcDesc.Desc, destDesc.Desc, ref destSizeInBytes);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnInitTransformDest", res));
            if (res != cudnnStatus.Success)
            {
                throw new CudaDNNException(res);
            }
            return(destSizeInBytes);
        }
        public SizeT GetAlgorithmSpaceSize(CudaDNNContext ctx)
        {
            SizeT size = new SizeT();

            res = CudaDNNNativeMethods.cudnnGetAlgorithmSpaceSize(ctx.Handle, _desc, ref size);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetAlgorithmSpaceSize", res));
            if (res != cudnnStatus.Success)
            {
                throw new CudaDNNException(res);
            }
            return(size);
        }
Esempio n. 23
0
 /* Set all data points of a tensor to a given value : srcDest = alpha * srcDest */
 public void ScaleTensor(TensorDescriptor srcDestDesc,
                         CudaDeviceVariable <double> srcDestData,
                         double alpha
                         )
 {
     res = CudaDNNNativeMethods.cudnnScaleTensor(_handle, srcDestDesc.Desc, srcDestData.DevicePointer, ref alpha);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnScaleTensor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Esempio n. 24
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);
        }
Esempio n. 25
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);
     }
 }
Esempio n. 26
0
        /// <summary>
        /// This function returns the size of the tensor in memory in respect to the given descriptor.
        /// This function can be used to know the amount of GPU memory to be allocated to hold that tensor.
        /// </summary>
        /// <returns>Size in bytes needed to hold the tensor in GPU memory.</returns>
        public SizeT GetTensorSizeInBytes()
        {
            SizeT retVal = 0;

            res = CudaDNNNativeMethods.cudnnGetTensorSizeInBytes(_desc, ref retVal);
            Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetTensorSizeInBytes", res));
            if (res != cudnnStatus.Success)
            {
                throw new CudaDNNException(res);
            }
            return(retVal);
        }
Esempio n. 27
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);
     }
 }
Esempio n. 28
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);
     }
 }
Esempio n. 29
0
 /// <summary>
 /// This function provides the output dimensions of a tensor after 2d pooling has been applied
 /// </summary>
 /// <param name="inputTensorDesc">Handle to the previously initialized input tensor descriptor.</param>
 /// <param name="n">Number of images in the output</param>
 /// <param name="c">Number of channels in the output</param>
 /// <param name="h">Height of images in the output</param>
 /// <param name="w">Width of images in the output</param>
 public void GetPooling2dForwardOutputDim(TensorDescriptor inputTensorDesc,
                                          ref int n,
                                          ref int c,
                                          ref int h,
                                          ref int w)
 {
     res = CudaDNNNativeMethods.cudnnGetPooling2dForwardOutputDim(_desc, inputTensorDesc.Desc, ref n, ref c, ref h, ref w);
     Debug.Write("");            //Line(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetPooling2dForwardOutputDim", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }
Esempio n. 30
0
 // Retrieve the settings currently stored in an LRN layer descriptor
 // Any of the provided pointers can be NULL (no corresponding value will be returned)
 public void GetLRNDescriptor(ref uint lrnN,
                              ref double lrnAlpha,
                              ref double lrnBeta,
                              ref double lrnK
                              )
 {
     res = CudaDNNNativeMethods.cudnnGetLRNDescriptor(_desc, ref lrnN, ref lrnAlpha, ref lrnBeta, ref lrnK);
     Debug.WriteLine(String.Format("{0:G}, {1}: {2}", DateTime.Now, "cudnnGetLRNDescriptor", res));
     if (res != cudnnStatus.Success)
     {
         throw new CudaDNNException(res);
     }
 }