Skip to main content

cutensorCreateContraction

Function cutensorCreateContraction 

Source
pub unsafe extern "C" fn cutensorCreateContraction(
    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,
    descCompute: cutensorComputeDescriptor_t,
) -> cutensorStatus_t
Expand description

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

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

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

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

Supported data-type combinations are:

typeAtypeBtypeCdescComputetypeScalarTensor Core
cudaDataType_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_16BFCUTENSOR_COMPUTE_DESC_32FcudaDataType_t::CUDA_R_32FAmpere+
cudaDataType_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_32FCUTENSOR_COMPUTE_DESC_TF32cudaDataType_t::CUDA_R_32FAmpere+
cudaDataType_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_32FCUTENSOR_COMPUTE_DESC_16BFcudaDataType_t::CUDA_R_32FAmpere+
cudaDataType_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_64FCUTENSOR_COMPUTE_DESC_64FcudaDataType_t::CUDA_R_64FAmpere+
cudaDataType_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_32FCUTENSOR_COMPUTE_DESC_32FcudaDataType_t::CUDA_C_32FNo
cudaDataType_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_32FCUTENSOR_COMPUTE_DESC_3XTF32cudaDataType_t::CUDA_C_32FAmpere+
cudaDataType_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_64FCUTENSOR_COMPUTE_DESC_32FcudaDataType_t::CUDA_C_64FNo
cudaDataType_t::CUDA_R_64FcudaDataType_t::CUDA_C_64FcudaDataType_t::CUDA_C_64FCUTENSOR_COMPUTE_DESC_64FcudaDataType_t::CUDA_C_64FNo
cudaDataType_t::CUDA_C_64FcudaDataType_t::CUDA_R_64FcudaDataType_t::CUDA_C_64FCUTENSOR_COMPUTE_DESC_64FcudaDataType_t::CUDA_C_64FNo
cudaDataType_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_64FCUTENSOR_COMPUTE_DESC_8XINT8cudaDataType_t::CUDA_C_64FHopper+
cudaDataType_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_32FCUTENSOR_COMPUTE_DESC_9X16BFcudaDataType_t::CUDA_C_32FHopper+
cudaDataType_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_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 descriptor that holds information about the data type, modes, and strides of D (must be identical to descC for now).
  • modeD: Array with ‘nmodeD’ entries that represent the modes of D (must be identical to modeC for now). The modeD[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