Esempio n. 1
0
 public static extern CudnnStatus cudnnSetTensor4dDescriptor(CudnnTensorDescriptorHandle tensorDesc,
                                                             CudnnTensorFormat format,
                                                             CudnnType 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
        public CudnnTensorDescriptorParameters(CudnnType type, CudnnTensorFormat format, int n, int c, int h, int w)
        {
            if (n < 1 || c < 1 || h < 1 || w < 1)
            {
                throw new ArgumentException("At least one of the parameters n, c, h, w was negative.");
            }

            this.Type = type;

            this.Num      = n;
            this.Channels = c;
            this.Height   = h;
            this.Width    = w;

            this.NumStride = h * w * c;

            if (format == CudnnTensorFormat.MajorRow)
            {
                this.ChannelsStride = h * w;
                this.HeightStride   = w;
                this.WidthStride    = 1;
            }
            else
            {
                this.ChannelsStride = 1;
                this.HeightStride   = w * c;
                this.WidthStride    = c;
            }
        }
 public static extern CudnnStatus cudnnSetTensor4dDescriptor(CudnnTensorDescriptorHandle tensorDesc,
                                                             CudnnTensorFormat format,
                                                             CudnnType 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);
        public CudnnTensorDescriptorParameters(CudnnType type, CudnnTensorFormat format, int n, int c, int h, int w)
        {
            if (n < 1 || c < 1 || h < 1 || w < 1)
                throw new ArgumentException("At least one of the parameters n, c, h, w was negative.");

            this.Type = type;

            this.Num = n;
            this.Channels = c;
            this.Height = h;
            this.Width = w;

            this.NumStride = h * w * c;

            if ( format == CudnnTensorFormat.MajorRow )
            {
                this.ChannelsStride = h * w;
                this.HeightStride = w;
                this.WidthStride = 1;
            }
            else
            {
                this.ChannelsStride = 1;
                this.HeightStride = w * c;
                this.WidthStride = c;
            }
        }