MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / get_convolution_forward_algorithm

Method get_convolution_forward_algorithm

crates/cudnn/src/context.rs:594–665  ·  view source on GitHub ↗

This function serves as a heuristic for obtaining the best suited algorithm for `convolution_forward()` for the given layer specifications. It will return the best algorithm according to an internal heuristic. # Arguments `x_desc` - previously initialized tensor descriptor for the input map. `w_desc` - previously initialized tensor descriptor for the filter map. `y_desc` - previously initiali

(
        &self,
        x_desc: &TensorDescriptor<T1, F1, D>,
        w_desc: &FilterDescriptor<T2, F2, D>,
        y_desc: &TensorDescriptor<T3, F3, D>,
        conv_desc: &ConvolutionDescriptor<Com

Source from the content-addressed store, hash-verified

592 /// # }
593 /// ```
594 pub fn get_convolution_forward_algorithm<
595 T1,
596 F1,
597 T2,
598 F2,
599 CompType,
600 T3,
601 F3,
602 const D: usize,
603 const N: usize,
604 >(
605 &self,
606 x_desc: &TensorDescriptor<T1, F1, D>,
607 w_desc: &FilterDescriptor<T2, F2, D>,
608 y_desc: &TensorDescriptor<T3, F3, D>,
609 conv_desc: &ConvolutionDescriptor<CompType, N>,
610 ) -> Result<BestHeuristic<sys::cudnnConvolutionFwdAlgo_t>, CudnnError>
611 where
612 T1: DataType,
613 F1: TensorFormat + SupportedType<T1>,
614 T2: DataType,
615 F2: TensorFormat + SupportedType<T2>,
616 CompType: DataType,
617 T3: DataType,
618 F3: TensorFormat + SupportedType<T3>,
619 BestHeuristic<sys::cudnnConvolutionFwdAlgo_t>:
620 SupportedConvFwd<T1, F1, T2, F2, CompType, T3, F3, D, N>,
621 {
622 let mut returned_algo_count = MaybeUninit::uninit();
623 let mut perf_results = MaybeUninit::uninit();
624
625 unsafe {
626 sys::cudnnGetConvolutionForwardAlgorithm_v7(
627 self.raw,
628 x_desc.raw,
629 w_desc.raw,
630 conv_desc.raw,
631 y_desc.raw,
632 1,
633 returned_algo_count.as_mut_ptr(),
634 perf_results.as_mut_ptr(),
635 )
636 .into_result()?;
637
638 let returned_algo_count = returned_algo_count.assume_init();
639
640 match returned_algo_count {
641 // This is general enough so that in the future it can be expanded to be more
642 // complex.
643 1 => {
644 let results: Vec<BestHeuristic<sys::cudnnConvolutionFwdAlgo_t>> = {
645 let raw_results = std::slice::from_raw_parts(
646 perf_results.as_ptr(),
647 returned_algo_count as usize,
648 );
649
650 raw_results
651 .iter()

Callers

nothing calls this directly

Calls 5

as_ptrMethod · 0.80
iterMethod · 0.80
from_raw_partsFunction · 0.50
into_resultMethod · 0.45
as_mut_ptrMethod · 0.45

Tested by

no test coverage detected