public void Backward(CudnnSoftmaxAlgorithm algorithm, CudnnSoftmaxMode mode, CudnnTensorDescriptor srcTensor, double[] srcData, CudnnTensorDescriptor srcDiffTensor, double[] srcDiffData, CudnnTensorDescriptor destDiffTensor, double[] destDiffData) { Contract.Requires(srcTensor != null); Contract.Requires(srcData != null); Contract.Requires(srcDiffTensor != null); Contract.Requires(srcDiffData != null); Contract.Requires(destDiffTensor != null); Contract.Requires(destDiffData != null); ThrowIfNotInitialized(); CheckIfCompatible(CudnnType.Double, srcTensor, srcDiffTensor, destDiffTensor); using (var srcDataGpu = new CudaDeviceVariable <double>(srcData.Length)) using (var srcDiffDataGpu = new CudaDeviceVariable <double>(srcDiffData.Length)) using (var destDiffDataGpu = new CudaDeviceVariable <double>(destDiffData.Length)) { srcDataGpu.CopyToDevice(srcData); srcDiffDataGpu.CopyToDevice(srcDiffData); Invoke(() => CudnnNativeMethods.cudnnSoftmaxBackward(handle, algorithm, mode, srcTensor.Handle, srcDataGpu.DevicePointer, srcDiffTensor.Handle, srcDiffDataGpu.DevicePointer, destDiffTensor.Handle, destDiffDataGpu.DevicePointer)); destDiffDataGpu.CopyToHost(destDiffData); } }
public void Backward(CudnnSoftmaxAlgorithm algorithm, CudnnSoftmaxMode mode, CudnnTensorDescriptor srcTensor, double[] srcData, CudnnTensorDescriptor srcDiffTensor, double[] srcDiffData, CudnnTensorDescriptor destDiffTensor, double[] destDiffData) { Contract.Requires(srcTensor != null); Contract.Requires(srcData != null); Contract.Requires(srcDiffTensor != null); Contract.Requires(srcDiffData != null); Contract.Requires(destDiffTensor != null); Contract.Requires(destDiffData != null); ThrowIfNotInitialized(); CheckIfCompatible(CudnnType.Double, srcTensor, srcDiffTensor, destDiffTensor); using (var srcDataGpu = new CudaDeviceVariable<double>(srcData.Length)) using (var srcDiffDataGpu = new CudaDeviceVariable<double>(srcDiffData.Length)) using (var destDiffDataGpu = new CudaDeviceVariable<double>(destDiffData.Length)) { srcDataGpu.CopyToDevice(srcData); srcDiffDataGpu.CopyToDevice(srcDiffData); Invoke(() => CudnnNativeMethods.cudnnSoftmaxBackward(handle, algorithm, mode, srcTensor.Handle, srcDataGpu.DevicePointer, srcDiffTensor.Handle, srcDiffDataGpu.DevicePointer, destDiffTensor.Handle, destDiffDataGpu.DevicePointer)); destDiffDataGpu.CopyToHost(destDiffData); } }
public static extern CudnnStatus cudnnSoftmaxForward( CudnnHandle handle, CudnnSoftmaxAlgorithm algorithm, CudnnSoftmaxMode mode, CudnnTensorDescriptorHandle srcDescriptor, [In] CUdeviceptr srcData, CudnnTensorDescriptorHandle destDescriptor, [In, Out] CUdeviceptr destData);
public void Forward(CudnnSoftmaxAlgorithm algorithm, CudnnSoftmaxMode 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.cudnnSoftmaxForward(handle, algorithm, mode, srcTensor.Handle, srcData.DevicePointer, destTensor.Handle, destData.DevicePointer)); }
public void Backward(CudnnSoftmaxAlgorithm algorithm, CudnnSoftmaxMode mode, CudnnTensorDescriptor srcTensor, CudaDeviceVariable<double> srcData, CudnnTensorDescriptor srcDiffTensor, CudaDeviceVariable<double> srcDiffData, CudnnTensorDescriptor destDiffTensor, CudaDeviceVariable<double> destDiffData) { Contract.Requires(srcTensor != null); Contract.Requires(srcData != null); Contract.Requires(srcDiffTensor != null); Contract.Requires(srcDiffData != null); Contract.Requires(destDiffTensor != null); Contract.Requires(destDiffData != null); ThrowIfNotInitialized(); CheckIfCompatible(CudnnType.Double, srcTensor, srcDiffTensor, destDiffTensor); Invoke(() => CudnnNativeMethods.cudnnSoftmaxBackward(handle, algorithm, mode, srcTensor.Handle, srcData.DevicePointer, srcDiffTensor.Handle, srcDiffData.DevicePointer, destDiffTensor.Handle, destDiffData.DevicePointer)); }