Backends/SiaNet.Backend.TensorSharp/Cuda/DNN.cs
/// <summary>
/// Gets the size of the convolution backward filter workspace.
/// </summary>
/// <param name="allocator">The allocator.</param>
/// <param name="algo">The algo.</param>
/// <param name="cd">The cd.</param>
/// <param name="x">The x.</param>
/// <param name="dy">The dy.</param>
/// <param name="dw">The dw.</param>
/// <returns>System.Int64.</returns>
/// <exception cref="InvalidOperationException">allocator must be a CUDA allocator</exception>
Gets the size of the convolution backward filter workspace.
Gets the size of the convolution backward filter workspace .
public static long GetConvolutionBackwardFilterWorkspaceSize(IAllocator allocator, DNNConvolutionBwdFilterAlgo algo, Cpu.ConvolutionDesc2d cd, TensorShape x, TensorShape dy, TensorShape dw)
        {
            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, x.ElementType);
                using (var xDesc = GetDescriptor(x))
                using (var dyDesc = GetDescriptor(dy))
                using (var dwDesc = GetFilterDescriptor(dw))
                {
                    return dnn.Value.GetConvolutionBackwardFilterWorkspaceSize(
                        xDesc,
                        dyDesc,
                        convDesc,
                        dwDesc,
                        (cudnnConvolutionBwdFilterAlgo)algo);
                }
            }
        }
public static long GetConvolutionBackwardFilterWorkspaceSize ( IAllocator allocator , DNNConvolutionBwdFilterAlgo algo , Cpu . ConvolutionDesc2d cd , TensorShape x , TensorShape dy , TensorShape dw ) { if ( ! ( allocator is CudaAllocator ) ) throw new InvalidOperationException ( " " ) ; var cudaAllocator = ( CudaAllocator ) allocator ; using ( var dnn = cudaAllocator . Context . DNNForDevice ( cudaAllocator . DeviceId ) ) { var convDesc = GetConvDescriptor ( cd , x . ElementType ) ; using ( var xDesc = GetDescriptor ( x ) ) using ( var dyDesc = GetDescriptor ( dy ) ) using ( var dwDesc = GetFilterDescriptor ( dw ) ) { return dnn . Value . GetConvolutionBackwardFilterWorkspaceSize ( xDesc , dyDesc , convDesc , dwDesc , ( cudnnConvolutionBwdFilterAlgo ) algo ) ; } } }
Gets the size of the convolution backward filter workspace.
Gets the size of the convolution backward filter workspace .
None
allocator must be a CUDA allocator
allocator must be a CUDA allocator
allocator
IAllocator
None
algo
DNNConvolutionBwdFilterAlgo
None
cd
Cpu.ConvolutionDesc2d
None
x
TensorShape
None
dy
TensorShape
None
dw
TensorShape
None