Ejemplo n.º 1
0
        public void Backward(CudnnActivationMode mode, CudnnTensorDescriptor srcTensor, double[] srcData, CudnnTensorDescriptor srcDiffTensor, double[] srcDiffData,
                             CudnnTensorDescriptor destTensor, double[] destData, CudnnTensorDescriptor destDiffTensor, double[] destDiffData)
        {
            Contract.Requires(srcTensor != null);
            Contract.Requires(srcData != null);
            Contract.Requires(destTensor != null);
            Contract.Requires(destData != null);
            Contract.Requires(srcDiffTensor != null);
            Contract.Requires(srcDiffData != null);
            Contract.Requires(destDiffTensor != null);
            Contract.Requires(destDiffData != null);

            ThrowIfNotInitialized();
            CheckIfCompatible(CudnnType.Double, srcTensor, srcDiffTensor, destTensor, destDiffTensor);

            using (var srcDataGpu = new CudaDeviceVariable <double>(srcData.Length))
                using (var srcDiffDataGpu = new CudaDeviceVariable <double>(srcDiffData.Length))
                    using (var destDataGpu = new CudaDeviceVariable <double>(destData.Length))
                        using (var destDiffDataGpu = new CudaDeviceVariable <double>(destDiffData.Length))
                        {
                            srcDataGpu.CopyToDevice(srcData);
                            srcDiffDataGpu.CopyToDevice(srcDiffData);
                            destDataGpu.CopyToDevice(destData);

                            Invoke(() => CudnnNativeMethods.cudnnActivationBackward(handle, mode,
                                                                                    srcTensor.Handle, srcDataGpu.DevicePointer, srcDiffTensor.Handle, srcDiffDataGpu.DevicePointer,
                                                                                    destTensor.Handle, destDataGpu.DevicePointer, destDiffTensor.Handle, destDiffDataGpu.DevicePointer));
                            destDiffDataGpu.CopyToHost(destDiffData);
                        }
        }
Ejemplo n.º 2
0
 public static extern CudnnStatus cudnnActivationForward(
                                     CudnnHandle handle,
                                     CudnnActivationMode mode,
                                     CudnnTensorDescriptorHandle srcDescriptor,
                                     [In] CUdeviceptr srcData,
                                     CudnnTensorDescriptorHandle destDescriptor,
                                     [In, Out] CUdeviceptr destData);
Ejemplo n.º 3
0
 public static extern CudnnStatus cudnnActivationForward(
     CudnnHandle handle,
     CudnnActivationMode mode,
     CudnnTensorDescriptorHandle srcDescriptor,
     [In] CUdeviceptr srcData,
     CudnnTensorDescriptorHandle destDescriptor,
     [In, Out] CUdeviceptr destData);
        public void Backward(CudnnActivationMode mode, CudnnTensorDescriptor srcTensor, float[] srcData, CudnnTensorDescriptor srcDiffTensor, float[] srcDiffData,
                                                       CudnnTensorDescriptor destTensor, float[] destData, CudnnTensorDescriptor destDiffTensor, float[] destDiffData)
        {
            Contract.Requires(srcTensor != null);
            Contract.Requires(srcData != null);
            Contract.Requires(destTensor != null);
            Contract.Requires(destData != null);
            Contract.Requires(srcDiffTensor != null);
            Contract.Requires(srcDiffData != null);
            Contract.Requires(destDiffTensor != null);
            Contract.Requires(destDiffData != null);

            ThrowIfNotInitialized();
            CheckIfCompatible(CudnnType.Float, srcTensor, srcDiffTensor, destTensor, destDiffTensor);

            using (var srcDataGpu = new CudaDeviceVariable<float>(srcData.Length))
            using (var srcDiffDataGpu = new CudaDeviceVariable<float>(srcDiffData.Length))
            using (var destDataGpu = new CudaDeviceVariable<float>(destData.Length))
            using (var destDiffDataGpu = new CudaDeviceVariable<float>(destDiffData.Length))
            {
                srcDataGpu.CopyToDevice(srcData);
                srcDiffDataGpu.CopyToDevice(srcDiffData);
                destDataGpu.CopyToDevice(destData);

                Invoke(() => CudnnNativeMethods.cudnnActivationBackward(handle, mode,
                                                                     srcTensor.Handle, srcDataGpu.DevicePointer, srcDiffTensor.Handle, srcDiffDataGpu.DevicePointer,
                                                                     destTensor.Handle, destDataGpu.DevicePointer, destDiffTensor.Handle, destDiffDataGpu.DevicePointer));
                destDiffDataGpu.CopyToHost(destDiffData);
            }
        }
Ejemplo n.º 5
0
        public void Forward(CudnnActivationMode mode, CudnnTensorDescriptor srcTensor, CudaDeviceVariable <double> srcData, CudnnTensorDescriptor destTensor, CudaDeviceVariable <double> destData)
        {
            Contract.Requires(srcTensor != null);
            Contract.Requires(srcData != null);
            Contract.Requires(destTensor != null);
            Contract.Requires(destData != null);

            ThrowIfNotInitialized();
            CheckIfCompatible(CudnnType.Double, srcTensor, destTensor);

            Invoke(() => CudnnNativeMethods.cudnnActivationForward(handle, mode, srcTensor.Handle, srcData.DevicePointer, destTensor.Handle, destData.DevicePointer));
        }
        public void Backward(CudnnActivationMode mode, CudnnTensorDescriptor srcTensor, CudaDeviceVariable<double> srcData, CudnnTensorDescriptor srcDiffTensor, CudaDeviceVariable<double> srcDiffData,
                                                       CudnnTensorDescriptor destTensor, CudaDeviceVariable<double> destData, CudnnTensorDescriptor destDiffTensor, CudaDeviceVariable<double> destDiffData)
        {
            Contract.Requires(srcTensor != null);
            Contract.Requires(srcData != null);
            Contract.Requires(destTensor != null);
            Contract.Requires(destData != null);
            Contract.Requires(srcDiffTensor != null);
            Contract.Requires(srcDiffData != null);
            Contract.Requires(destDiffTensor != null);
            Contract.Requires(destDiffData != null);

            ThrowIfNotInitialized();
            CheckIfCompatible(CudnnType.Double, srcTensor, srcDiffTensor, destTensor, destDiffTensor);

            Invoke(() => CudnnNativeMethods.cudnnActivationBackward(handle, mode,
                                srcTensor.Handle, srcData.DevicePointer, srcDiffTensor.Handle, srcDiffData.DevicePointer,
                                destTensor.Handle, destData.DevicePointer, destDiffTensor.Handle, destDiffData.DevicePointer));
        }