Backends/SiaNet.Backend.TensorSharp/Cuda/DNN.cs
/// <summary>
/// Gets the size of the convolution forward 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="w">The w.</param>
/// <param name="y">The y.</param>
/// <returns>System.Int64.</returns>
/// <exception cref="InvalidOperationException">allocator must be a CUDA allocator</exception>
Gets the size of the convolution forward workspace.
Gets the size of the convolution forward workspace .
public static long GetConvolutionForwardWorkspaceSize(IAllocator allocator, DNNConvolutionFwdAlgo algo, Cpu.ConvolutionDesc2d cd, TensorShape x, TensorShape w, TensorShape y)
        {
            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 wDesc = GetFilterDescriptor(w))
                using (var yDesc = GetDescriptor(y))
                {
                    return dnn.Value.GetConvolutionForwardWorkspaceSize(
                        xDesc,
                        wDesc,
                        convDesc,
                        yDesc,
                        (cudnnConvolutionFwdAlgo)algo);
                }
            }
        }
public static long GetConvolutionForwardWorkspaceSize ( IAllocator allocator , DNNConvolutionFwdAlgo algo , Cpu . ConvolutionDesc2d cd , TensorShape x , TensorShape w , TensorShape y ) { 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 wDesc = GetFilterDescriptor ( w ) ) using ( var yDesc = GetDescriptor ( y ) ) { return dnn . Value . GetConvolutionForwardWorkspaceSize ( xDesc , wDesc , convDesc , yDesc , ( cudnnConvolutionFwdAlgo ) algo ) ; } } }
Gets the size of the convolution forward workspace.
Gets the size of the convolution forward workspace .
None
allocator must be a CUDA allocator
allocator must be a CUDA allocator
allocator
IAllocator
None
algo
DNNConvolutionFwdAlgo
None
cd
Cpu.ConvolutionDesc2d
None
x
TensorShape
None
w
TensorShape
None
y
TensorShape
None