Skip to main content

cutensorCreateContractionTrinary

Function cutensorCreateContractionTrinary 

Source
pub unsafe extern "C" fn cutensorCreateContractionTrinary(
    handle: cutensorHandle_t,
    desc: *mut cutensorOperationDescriptor_t,
    descA: cutensorTensorDescriptor_t,
    modeA: *const i32,
    opA: cutensorOperator_t,
    descB: cutensorTensorDescriptor_t,
    modeB: *const i32,
    opB: cutensorOperator_t,
    descC: cutensorTensorDescriptor_t,
    modeC: *const i32,
    opC: cutensorOperator_t,
    descD: cutensorTensorDescriptor_t,
    modeD: *const i32,
    opD: cutensorOperator_t,
    descE: cutensorTensorDescriptor_t,
    modeE: *const i32,
    descCompute: cutensorComputeDescriptor_t,
) -> cutensorStatus_t
Expand description

This function allocates a cutensorOperationDescriptor_t object that encodes a tensor contraction of the form $\mathcal{E} = \alpha \mathcal{A} \mathcal{B} \mathcal{C} + \beta \mathcal{D}$.

Allocates data for desc to be used to perform a tensor contraction of the form: $$ \mathcal{E}{{modes}\mathcal{E}} \gets \alpha op_\mathcal{A}(\mathcal{A}{{modes}\mathcal{A}}) op_\mathcal{B}(\mathcal{B}{{modes}\mathcal{B}}) op_\mathcal{C}(\mathcal{C}{{modes}\mathcal{C}}) + \beta op_\mathcal{D}(\mathcal{D}{{modes}\mathcal{D}}). $$

See cutensorCreatePlan (or cutensorCreatePlanAutotuned) to create the plan (i.e., to select the kernel) followed by a call to cutensorContractTrinary to perform the actual contraction.

The user is responsible for calling cutensorDestroyOperationDescriptor to free the resources associated with the descriptor.

The performance improvements due to this API are currently especially high if your data resides on the host (i.e. out-of-core), targeting Grace-based systems.

Supported data-type combinations are:

typeAtypeBtypeCtypeDdescComputetypeScalarTensor Core
cudaDataType_t::CUDA_R_16FcudaDataType_t::CUDA_R_16FcudaDataType_t::CUDA_R_16FcudaDataType_t::CUDA_R_16FCUTENSOR_COMPUTE_DESC_32FcudaDataType_t::CUDA_R_32FVolta+
cudaDataType_t::CUDA_R_16BFcudaDataType_t::CUDA_R_16BFcudaDataType_t::CUDA_R_16BFcudaDataType_t::CUDA_R_16BFCUTENSOR_COMPUTE_DESC_32FcudaDataType_t::CUDA_R_32FAmpere+
cudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FCUTENSOR_COMPUTE_DESC_32FcudaDataType_t::CUDA_R_32FNo
cudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FCUTENSOR_COMPUTE_DESC_TF32cudaDataType_t::CUDA_R_32FAmpere+
cudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FCUTENSOR_COMPUTE_DESC_3XTF32cudaDataType_t::CUDA_R_32FAmpere+
cudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FCUTENSOR_COMPUTE_DESC_16BFcudaDataType_t::CUDA_R_32FAmpere+
cudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FCUTENSOR_COMPUTE_DESC_16FcudaDataType_t::CUDA_R_32FVolta+
cudaDataType_t::CUDA_R_64FcudaDataType_t::CUDA_R_64FcudaDataType_t::CUDA_R_64FcudaDataType_t::CUDA_R_64FCUTENSOR_COMPUTE_DESC_64FcudaDataType_t::CUDA_R_64FAmpere+
cudaDataType_t::CUDA_R_64FcudaDataType_t::CUDA_R_64FcudaDataType_t::CUDA_R_64FcudaDataType_t::CUDA_R_64FCUTENSOR_COMPUTE_DESC_32FcudaDataType_t::CUDA_R_64FNo
cudaDataType_t::CUDA_C_32FcudaDataType_t::CUDA_C_32FcudaDataType_t::CUDA_C_32FcudaDataType_t::CUDA_C_32FCUTENSOR_COMPUTE_DESC_32FcudaDataType_t::CUDA_C_32FNo
cudaDataType_t::CUDA_C_32FcudaDataType_t::CUDA_C_32FcudaDataType_t::CUDA_C_32FcudaDataType_t::CUDA_C_32FCUTENSOR_COMPUTE_DESC_TF32cudaDataType_t::CUDA_C_32FAmpere+
cudaDataType_t::CUDA_C_32FcudaDataType_t::CUDA_C_32FcudaDataType_t::CUDA_C_32FcudaDataType_t::CUDA_C_32FCUTENSOR_COMPUTE_DESC_3XTF32cudaDataType_t::CUDA_C_32FAmpere+
cudaDataType_t::CUDA_C_64FcudaDataType_t::CUDA_C_64FcudaDataType_t::CUDA_C_64FcudaDataType_t::CUDA_C_64FCUTENSOR_COMPUTE_DESC_64FcudaDataType_t::CUDA_C_64FAmpere+
cudaDataType_t::CUDA_C_64FcudaDataType_t::CUDA_C_64FcudaDataType_t::CUDA_C_64FcudaDataType_t::CUDA_C_64FCUTENSOR_COMPUTE_DESC_32FcudaDataType_t::CUDA_C_64FNo
cudaDataType_t::CUDA_R_64FcudaDataType_t::CUDA_R_64FcudaDataType_t::CUDA_R_64FcudaDataType_t::CUDA_R_64FCUTENSOR_COMPUTE_DESC_8XINT8cudaDataType_t::CUDA_R_64FHopper+
cudaDataType_t::CUDA_C_64FcudaDataType_t::CUDA_C_64FcudaDataType_t::CUDA_C_64FcudaDataType_t::CUDA_C_64FCUTENSOR_COMPUTE_DESC_8XINT8cudaDataType_t::CUDA_C_64FHopper+
cudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FCUTENSOR_COMPUTE_DESC_9X16BFcudaDataType_t::CUDA_R_32FHopper+
cudaDataType_t::CUDA_C_32FcudaDataType_t::CUDA_C_32FcudaDataType_t::CUDA_C_32FcudaDataType_t::CUDA_C_32FCUTENSOR_COMPUTE_DESC_9X16BFcudaDataType_t::CUDA_C_32FHopper+
cudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FcudaDataType_t::CUDA_R_32FCUTENSOR_COMPUTE_DESC_4X16FcudaDataType_t::CUDA_R_32FBlackwell+
cudaDataType_t::CUDA_C_32FcudaDataType_t::CUDA_C_32FcudaDataType_t::CUDA_C_32FcudaDataType_t::CUDA_C_32FCUTENSOR_COMPUTE_DESC_4X16FcudaDataType_t::CUDA_C_32FBlackwell+

§Parameters

  • handle: Opaque handle holding cuTENSOR’s library context.
  • desc: This opaque struct gets allocated and filled with the information that encodes the tensor contraction operation.
  • descA: The descriptor that holds the information about the data type, modes and strides of A.
  • modeA: Array with ‘nmodeA’ entries that represent the modes of A. The modeA[i] corresponds to extent[i] and stride[i] with respect to the arguments provided to cutensorInitTensorDescriptor.
  • opA: Unary operator that will be applied to each element of A before it is further processed. The original data of this tensor remains unchanged.
  • descB: The descriptor that holds information about the data type, modes, and strides of B.
  • modeB: Array with ‘nmodeB’ entries that represent the modes of B. The modeB[i] corresponds to extent[i] and stride[i] with respect to the arguments provided to cutensorInitTensorDescriptor.
  • opB: Unary operator that will be applied to each element of B before it is further processed. The original data of this tensor remains unchanged.
  • descC: The escriptor that holds information about the data type, modes, and strides of C.
  • modeC: Array with ‘nmodeC’ entries that represent the modes of C. The modeC[i] corresponds to extent[i] and stride[i] with respect to the arguments provided to cutensorInitTensorDescriptor.
  • opC: Unary operator that will be applied to each element of C before it is further processed. The original data of this tensor remains unchanged.
  • descD: The escriptor that holds information about the data type, modes, and strides of D.
  • modeD: Array with ‘nmodeD’ entries that represent the modes of D. The modeD[i] corresponds to extent[i] and stride[i] with respect to the arguments provided to cutensorInitTensorDescriptor.
  • opD: Unary operator that will be applied to each element of D before it is further processed. The original data of this tensor remains unchanged.
  • descE: The descriptor that holds information about the data type, modes, and strides of E (must be identical to descD for now).
  • modeE: Array with ‘nmodeE’ entries that represent the modes of E (must be identical to modeD for now). The modeE[i] corresponds to extent[i] and stride[i] with respect to the arguments provided to cutensorInitTensorDescriptor.
  • descCompute: Determines the precision in which this operations is performed.

§Return value