Backends/SiaNet.Backend.TensorSharp/Cuda/DNN.cs
/// <summary>
/// Gets the size of the convolution backward data workspace.
/// </summary>
/// <param name="allocator">The allocator.</param>
/// <param name="algo">The algo.</param>
/// <param name="cd">The cd.</param>
/// <param name="w">The w.</param>
/// <param name="dy">The dy.</param>
/// <param name="dx">The dx.</param>
/// <returns>System.Int64.</returns>
/// <exception cref="InvalidOperationException">allocator must be a CUDA allocator</exception>
Gets the size of the convolution backward data workspace.
Gets the size of the convolution backward data workspace .
public static long GetConvolutionBackwardDataWorkspaceSize(IAllocator allocator, DNNConvolutionBwdDataAlgo algo, Cpu.ConvolutionDesc2d cd, TensorShape w, TensorShape dy, TensorShape dx)
        {
            if (!(allocator is CudaAllocator))
                throw new InvalidOperationException("allocator must be a CUDA allocator");
            var cudaAllocator = (CudaAllocator)allocator;
            using (var dnn = cudaAllocator.Context.DNNForDevice(cudaAllocator.DeviceId))
            {
                var convDesc = GetConvDescriptor(cd, w.ElementType);
                using (var wDesc = GetFilterDescriptor(w))
                using (var dyDesc = GetDescriptor(dy))
                using (var dxDesc = GetDescriptor(dx))
                {
                    return dnn.Value.GetConvolutionBackwardDataWorkspaceSize(
                        wDesc,
                        dyDesc,
                        convDesc,
                        dxDesc,
                        (cudnnConvolutionBwdDataAlgo)algo);
                }
            }
        }
public static long GetConvolutionBackwardDataWorkspaceSize ( IAllocator allocator , DNNConvolutionBwdDataAlgo algo , Cpu . ConvolutionDesc2d cd , TensorShape w , TensorShape dy , TensorShape dx ) { if ( ! ( allocator is CudaAllocator ) ) throw new InvalidOperationException ( " " ) ; var cudaAllocator = ( CudaAllocator ) allocator ; using ( var dnn = cudaAllocator . Context . DNNForDevice ( cudaAllocator . DeviceId ) ) { var convDesc = GetConvDescriptor ( cd , w . ElementType ) ; using ( var wDesc = GetFilterDescriptor ( w ) ) using ( var dyDesc = GetDescriptor ( dy ) ) using ( var dxDesc = GetDescriptor ( dx ) ) { return dnn . Value . GetConvolutionBackwardDataWorkspaceSize ( wDesc , dyDesc , convDesc , dxDesc , ( cudnnConvolutionBwdDataAlgo ) algo ) ; } } }
Gets the size of the convolution backward data workspace.
Gets the size of the convolution backward data workspace .
None
allocator must be a CUDA allocator
allocator must be a CUDA allocator
allocator
IAllocator
None
algo
DNNConvolutionBwdDataAlgo
None
cd
Cpu.ConvolutionDesc2d
None
w
TensorShape
None
dy
TensorShape
None
dx
TensorShape
None