Skip to main content

cutensorContractTrinary

Function cutensorContractTrinary 

Source
pub unsafe extern "C" fn cutensorContractTrinary(
    handle: cutensorHandle_t,
    plan: cutensorPlan_t,
    alpha: *const c_void,
    A: *const c_void,
    B: *const c_void,
    C: *const c_void,
    beta: *const c_void,
    D: *const c_void,
    E: *mut c_void,
    workspace: *mut c_void,
    workspaceSize: u64,
    stream: cudaStream_t,
) -> cutensorStatus_t
Expand description

This routine computes the tensor contraction $E = alpha \* A \* B \* C + beta \* D$. $$ \mathcal{E}{{modes}\mathcal{E}} \gets \alpha \* \mathcal{A}{{modes}\mathcal{A}} \mathcal{B}{{modes}\mathcal{B}} \mathcal{C}{{modes}\mathcal{C}} + \beta \mathcal{D}{{modes}\mathcal{D}} $$

The active CUDA device must match the CUDA device that was active at the time at which the plan was created.

[Example] : See NVIDIA/CUDALibrarySamples for a concrete example.

§Parameters

  • handle: Opaque handle holding cuTENSOR’s library context.
  • plan: Opaque handle holding the contraction execution plan (created by cutensorCreateContractionTrinary followed by cutensorCreatePlan).
  • alpha: Scaling for A*B*C. Its data type is determined by ‘descCompute’ (see cutensorOperationDescriptorGetAttribute(desc, CUTENSOR_OPERATION_SCALAR_TYPE)). Pointer to the host memory.
  • A: Pointer to the data corresponding to A. Pointer to the GPU-accessible memory. The data accessed via this pointer must not overlap with the elements written to E.
  • B: Pointer to the data corresponding to B. Pointer to the GPU-accessible memory. The data accessed via this pointer must not overlap with the elements written to E.
  • C: Pointer to the data corresponding to C. Pointer to the GPU-accessible memory. The data accessed via this pointer must not overlap with the elements written to E.
  • beta: Scaling for D. Its data type is determined by ‘descCompute’ (see cutensorOperationDescriptorGetAttribute(desc, CUTENSOR_OPERATION_SCALAR_TYPE)). Pointer to the host memory.
  • D: Pointer to the data corresponding to D. Pointer to the GPU-accessible memory.
  • E: Pointer to the data corresponding to E. Pointer to the GPU-accessible memory.
  • workspace: Optional parameter that may be NULL. This pointer provides additional workspace, in device memory, to the library for additional optimizations; the workspace must be aligned to 256 bytes (i.e., the default alignment of cudaMalloc).
  • workspaceSize: Size of the workspace array in bytes; please refer to cutensorEstimateWorkspaceSize to query the required workspace. While cutensorContract does not strictly require a workspace for the contraction, it is still recommended to provide some small workspace (e.g., 128 MB).
  • stream: The CUDA stream in which all the computation is performed.

§Return value